From 095887cb875f92ebf2f5554c8abd2d4805c6bde5 Mon Sep 17 00:00:00 2001 From: lijianguo Date: Thu, 24 Feb 2022 11:12:07 +0800 Subject: [PATCH] chore(dockerfile): use drycc/base image --- Dockerfile | 43 +++++++++++++++++++++++++++++++-------- contrib/ci/test.sh | 2 +- main.go | 2 +- rootfs/config-example.yml | 18 ++++++++++++++++ 4 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 rootfs/config-example.yml diff --git a/Dockerfile b/Dockerfile index 7d18242..0acc97f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,49 @@ -FROM docker.io/minio/mc:latest as mc - - FROM docker.io/drycc/go-dev:latest AS build ARG LDFLAGS ADD . /app RUN export GO111MODULE=on \ && cd /app \ - && CGO_ENABLED=0 go build -ldflags "${LDFLAGS}" -o /usr/local/bin/registry main.go \ + && CGO_ENABLED=0 init-stack go build -ldflags "${LDFLAGS}" -o /usr/local/bin/registry main.go \ && upx -9 --brute /usr/local/bin/registry -FROM docker.io/library/registry:2.7 +FROM docker.io/drycc/base:bullseye + +RUN adduser --system \ + --shell /bin/bash \ + --disabled-password \ + --home /var/lib/registry \ + --group \ + drycc -COPY rootfs / -COPY --from=mc /usr/bin/mc /bin/mc +COPY rootfs/bin/ /bin/ +COPY rootfs/config-example.yml /etc/docker/registry/config.yml COPY --from=build /usr/local/bin/registry /opt/registry/sbin/registry +ENV JQ_VERSION="1.6" \ + MC_VERSION="RELEASE.2022-02-26T03-58-31Z" \ + REGISTRY_VERSION="2.8.0" -RUN apk add --no-cache jq bash \ - && chmod +x /bin/create_bucket /bin/normalize_storage +RUN install-stack jq $JQ_VERSION \ + && install-stack mc $MC_VERSION \ + && install-stack registry $REGISTRY_VERSION \ + && chmod +x /bin/create_bucket /bin/normalize_storage \ + && rm -rf \ + /usr/share/doc \ + /usr/share/man \ + /usr/share/info \ + /usr/share/locale \ + /var/lib/apt/lists/* \ + /var/log/* \ + /var/cache/debconf/* \ + /etc/systemd \ + /lib/lsb \ + /lib/udev \ + /usr/lib/`echo $(uname -m)`-linux-gnu/gconv/IBM* \ + /usr/lib/`echo $(uname -m)`-linux-gnu/gconv/EBC* \ + && mkdir -p /usr/share/man/man{1..8} \ + && chown -R drycc:drycc /var/lib/registry +USER drycc VOLUME ["/var/lib/registry"] CMD ["/opt/registry/sbin/registry"] EXPOSE 5000 diff --git a/contrib/ci/test.sh b/contrib/ci/test.sh index a0c143c..13cd969 100755 --- a/contrib/ci/test.sh +++ b/contrib/ci/test.sh @@ -12,7 +12,7 @@ echo "1234567890123456789012345678901234567890" > "${CURRENT_DIR}"/tmp/aws-user/ MINIO_JOB=$(docker run -d --name minio \ -v "${CURRENT_DIR}"/tmp/aws-user:/var/run/secrets/drycc/objectstore/creds \ - drycc/minio:canary server /home/minio/) + drycc/minio:canary server /data/minio/) sleep 5 docker logs "${MINIO_JOB}" diff --git a/main.go b/main.go index 407a145..d0b23f0 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,7 @@ import ( ) const ( - registryBinary = "/bin/registry" + registryBinary = "/opt/drycc/registry/bin/registry" registryConfig = "/etc/docker/registry/config.yml" minioHostEnvVar = "DRYCC_MINIO_SERVICE_HOST" minioPortEnvVar = "DRYCC_MINIO_SERVICE_PORT" diff --git a/rootfs/config-example.yml b/rootfs/config-example.yml new file mode 100644 index 0000000..3277f9a --- /dev/null +++ b/rootfs/config-example.yml @@ -0,0 +1,18 @@ +version: 0.1 +log: + fields: + service: registry +storage: + cache: + blobdescriptor: inmemory + filesystem: + rootdirectory: /var/lib/registry +http: + addr: :5000 + headers: + X-Content-Type-Options: [nosniff] +health: + storagedriver: + enabled: true + interval: 10s + threshold: 3