1
0
Fork 0

use multi-stage builds
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Daniel Wolf 2022-04-21 14:32:08 -04:00
parent 3073392dee
commit 1c37a94651
Signed by: nephatrine
GPG Key ID: 59D70EC2E4AAB4D0
2 changed files with 53 additions and 27 deletions

View File

@ -9,19 +9,37 @@ platform:
steps:
- name: build
environment:
PDR_USER:
from_secret: docker-user-pdr
PDR_PASS:
from_secret: docker-pass-pdr
commands:
- docker build -t pdr.nephatrine.net/nephatrine/docker-registry:cached --target builder .
- docker build -t pdr.nephatrine.net/nephatrine/docker-registry:latest .
- HOME=/mnt/config/home docker push pdr.nephatrine.net/nephatrine/docker-registry:latest
- docker login -p "$PDR_PASS" -u "$PDR_USER" pdr.nephatrine.net
- docker push pdr.nephatrine.net/nephatrine/docker-registry:latest
- docker logout pdr.nephatrine.net
- name: publish
environment:
DOCKER_USER:
from_secret: docker-user
DOCKER_PASS:
from_secret: docker-pass
commands:
- docker tag pdr.nephatrine.net/nephatrine/docker-registry:latest nephatrine/docker-registry:latest
- HOME=/mnt/config/home docker push nephatrine/docker-registry:latest
- docker rmi pdr.nephatrine.net/nephatrine/docker-registry:latest
- docker login -p "$DOCKER_PASS" -u "$DOCKER_USER"
- docker push -a nephatrine/docker-registry
- docker logout
depends_on:
- build
---
kind: pipeline
name: after
name: notify
steps:
- name: notify
- name: notify-status
image: appleboy/drone-discord
failure: ignore
settings:
@ -43,6 +61,6 @@ trigger:
---
kind: signature
hmac: ab81157fca9939dba824db6bb99810381fb9456e60530fda7de594e0d0d9c222
hmac: a9f729c5834505eb4cf79b1050ad4f06ab1270c110d4abab52e948fd139bfc92
...

View File

@ -1,27 +1,35 @@
FROM nephatrine/alpine-s6:latest
FROM pdr.nephatrine.net/nephatrine/alpine-builder:latest AS builder
ARG GOPATH="/usr"
ARG BUILDTAGS="include_oss include_gcs"
ARG REGISTRY_VERSION=main
ARG REGCLIENT_VERSION=releases/0.4
RUN mkdir -p /usr/src/github.com/distribution \
&& git -C /usr/src/github.com/distribution clone -b "$REGISTRY_VERSION" --single-branch --depth=1 https://github.com/distribution/distribution.git
RUN git -C /usr/src clone -b "$REGCLIENT_VERSION" --single-branch --depth=1 https://github.com/regclient/regclient.git
RUN echo "====== COMPILE REGISTRY ======" \
&& cd /usr/src/github.com/distribution/distribution \
&& go build -i . \
&& make build -j4 \
&& make binaries -j4
RUN echo "====== COMPILE REGCLIENT ======" \
&& cd /usr/src/regclient \
&& make binaries -j4
FROM pdr.nephatrine.net/nephatrine/alpine-s6:latest
LABEL maintainer="Daniel Wolf <nephatrine@gmail.com>"
ARG REGISTRY_VERSION=main
ARG REGCLIENT_VERSION=main
ARG BUILDTAGS="include_oss include_gcs"
ARG GOPATH="/usr"
RUN echo "====== COMPILE REGISTRY ======" \
&& mkdir /etc/registry \
&& apk add --no-cache --virtual .build-registry \
git go \
make \
&& mkdir -p /usr/src/github.com/distribution \
&& git -C /usr/src/github.com/distribution clone -b "$REGISTRY_VERSION" --single-branch --depth=1 https://github.com/distribution/distribution.git \
&& cd /usr/src/github.com/distribution/distribution && go build -i . \
&& make build -j4 && make binaries -j4 && install -m 0755 bin/registry /usr/bin/ \
&& cp cmd/registry/config-example.yml /etc/registry/config-example.yml \
RUN mkdir /etc/registry
COPY --from=builder /usr/src/github.com/distribution/distribution/bin/ /usr/bin/
COPY --from=builder /usr/src/regclient/bin/ /usr/local/bin/
COPY --from=builder /usr/src/github.com/distribution/distribution/cmd/registry/config-example.yml /etc/registry/config-example.yml
COPY override /
RUN echo "====== CONFIGURE REGISTRY ======" \
&& cp /etc/registry/config-example.yml /etc/registry/config.yml \
&& sed -i 's~/var/lib/registry~/mnt/config/data~g' /etc/registry/config.yml \
&& sed -i 's~/etc/registry~/mnt/config/etc/registry~g' /etc/registry/config.yml \
&& git -C /usr/src clone -b "$REGCLIENT_VERSION" --single-branch --depth=1 https://github.com/regclient/regclient.git \
&& cd /usr/src/regclient && make && install -m 0755 bin/regctl bin/regsync bin/regbot /usr/bin/ \
&& cd /usr/src && rm -rf /usr/pkg/* /usr/src/* \
&& apk del --purge .build-registry
&& sed -i 's~/etc/registry~/mnt/config/etc/registry~g' /etc/registry/config.yml
COPY override /
EXPOSE 5000/tcp