Skip to content

Commit cebc07d

Browse files
committed
feat(registry): use docker build
1 parent c8eddc7 commit cebc07d

3 files changed

Lines changed: 30 additions & 16 deletions

File tree

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM minio/mc:latest as mc
2+
3+
4+
FROM drycc/go-dev:latest AS build
5+
ARG LDFLAGS
6+
ADD . /app
7+
RUN export GO111MODULE=on \
8+
&& cd /app \
9+
&& CGO_ENABLED=0 go build -ldflags "${LDFLAGS}" -o /usr/local/bin/registry main.go \
10+
&& upx -9 --brute /usr/local/bin/registry
11+
12+
13+
FROM registry:2.7
14+
15+
COPY rootfs /
16+
COPY --from=mc /usr/bin/mc /bin/mc
17+
COPY --from=build /usr/local/bin/registry /opt/registry/sbin/registry
18+
19+
RUN apk add --no-cache jq bash \
20+
&& chmod +x /bin/create_bucket /bin/normalize_storage
21+
22+
VOLUME ["/var/lib/registry"]
23+
CMD ["/opt/registry/sbin/registry"]
24+
EXPOSE 5000

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# - Docker image name
44
# - Kubernetes service, deployment, pod names
55
SHORT_NAME := registry
6+
PLATFORM ?= linux/amd64,linux/arm64
67

78
include includes.mk versioning.mk
89

@@ -36,10 +37,13 @@ build: check-docker
3637

3738
# For cases where we're building from local
3839
# We also alter the RC file to set the image name.
39-
docker-build: check-docker build
40-
docker build ${DOCKER_BUILD_FLAGS} -t ${IMAGE} rootfs
40+
docker-build: check-docker
41+
docker build ${DOCKER_BUILD_FLAGS} -t ${IMAGE} --build-arg LDFLAGS=${LDFLAGS} .
4142
docker tag ${IMAGE} ${MUTABLE_IMAGE}
4243

44+
docker-buildx: check-docker
45+
docker buildx build --platform ${PLATFORM} -t ${IMAGE} --build-arg LDFLAGS=${LDFLAGS} . --push
46+
4347
build-binary:
4448
${DEV_ENV_CMD} go build -ldflags ${LDFLAGS} -o $(BINDIR)/${SHORT_NAME} main.go
4549
$(call check-static-binary,$(BINDIR)/${SHORT_NAME})

rootfs/Dockerfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)