1
0

ci: fix tests w/ upstream nginx-proxy & docker-gen

This commit is contained in:
Nicolas Duchon 2021-04-26 16:10:56 +02:00
parent 03787386d1
commit 61e5156ed3
No known key found for this signature in database
GPG Key ID: EA3151C66A4D79E7
3 changed files with 13 additions and 125 deletions

@ -24,10 +24,6 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Patch the Dockerfile's docker-gen
run: |
sed -i 's#DOCKER_GEN_VERSION=.*$#DOCKER_GEN_VERSION=fix-current-container-id#g' Dockerfile
sed -i 's#go get github.com/jwilder/docker-gen#go get github.com/buchdag/docker-gen \&\& mv /go/src/github.com/buchdag /go/src/github.com/jwilder#g' Dockerfile
- name: Build Image
run: docker build -t "$IMAGE" .
- name: Inspect Image
@ -44,16 +40,16 @@ jobs:
name: companion.tar
path: companion.tar
nginx-proxy-build:
nginx-proxy-pull:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Build patched nginx-proxy Image
run: docker build -t "nginxproxy/nginx-proxy:latest" ./test/setup/nginx-proxy
- name: Build patched docker-gen Image
run: docker build -t "jwilder/docker-gen:latest" ./test/setup/docker-gen
- name: Pull nginx-proxy Image
run: docker pull nginxproxy/nginx-proxy:latest
- name: Pull docker-gen Image
run: docker pull jwilder/docker-gen:latest
- name: List Docker Images
run: docker images
- name: Export Images Artifacts
@ -95,7 +91,7 @@ jobs:
integration-tests:
needs:
- companion-build
- nginx-proxy-build
- nginx-proxy-pull
strategy:
fail-fast: false
matrix:
@ -145,29 +141,29 @@ jobs:
- name: Setup Boulder
if: ${{ matrix.acme-ca == 'boulder' }}
run: test/setup/setup-boulder.sh
- name: Download nginx-proxy Patched Image
- name: Download nginx-proxy Image
uses: actions/download-artifact@v2
with:
name: nginx-proxy.tar
- name: Download docker-gen Patched Image
- name: Download docker-gen Image
uses: actions/download-artifact@v2
with:
name: docker-gen.tar
- name: Import nginx-proxy patched Images
- name: Import nginx-proxy Images
run: |
docker load < nginx-proxy.tar
docker load < docker-gen.tar
- name: Setup NGINX Proxy
- name: Setup nginx-proxy
env:
SETUP: ${{ matrix.setup }}
ACME_CA: ${{ matrix.acme-ca }}
run: test/setup/setup-nginx-proxy.sh
# ADD BUILDED IMAGE
- name: Download Builded Image
# ADD BUILT IMAGE
- name: Download Built Image
uses: actions/download-artifact@v2
with:
name: companion.tar
- name: Import Builded Image
- name: Import Built Image
run: docker load < companion.tar
# TEST
- name: Integration Testing

@ -1,37 +0,0 @@
FROM golang:1.15-alpine AS build-docker-gen
ARG DOCKER_GEN_VERSION=fix-current-container-id
LABEL stage=intermediate
# Install build dependencies for docker-gen
RUN apk add --update \
curl \
gcc \
git \
make \
musl-dev
# Build docker-gen
RUN go get github.com/buchdag/docker-gen \
&& mv /go/src/github.com/buchdag /go/src/github.com/jwilder \
&& cd /go/src/github.com/jwilder/docker-gen \
&& git -c advice.detachedHead=false checkout $DOCKER_GEN_VERSION \
&& make get-deps \
&& make all
FROM alpine:3.8
LABEL maintainer="Nicolas Duchon <nicolas.duchon@gmail.com>"
# DOCKER_GEN_VERSION environment variable is required by acme-companion
ENV DOCKER_GEN_VERSION=0.7.4 \
DOCKER_HOST=unix:///tmp/docker.sock
# Copy docker-gen binary from build stage
COPY --from=build-docker-gen /go/src/github.com/jwilder/docker-gen/docker-gen /usr/local/bin/
# Get latest nginx.tmpl
ADD https://raw.githubusercontent.com/nginx-proxy/nginx-proxy/main/nginx.tmpl /etc/docker-gen/templates/
ENTRYPOINT ["/usr/local/bin/docker-gen"]

@ -1,71 +0,0 @@
FROM golang:1.15-alpine AS go-builder
ARG DOCKER_GEN_VERSION=fix-current-container-id
ARG FOREGO_VERSION=20180216151118
LABEL stage=intermediate
# Install build dependencies for docker-gen and forego
RUN apk add --update \
curl \
gcc \
git \
make \
musl-dev
# Build forego
RUN go get github.com/ddollar/forego \
&& cd /go/src/github.com/ddollar/forego \
&& git -c advice.detachedHead=false checkout $FOREGO_VERSION \
&& make all
# Build docker-gen
RUN go get github.com/buchdag/docker-gen \
&& mv /go/src/github.com/buchdag /go/src/github.com/jwilder \
&& cd /go/src/github.com/jwilder/docker-gen \
&& git -c advice.detachedHead=false checkout $DOCKER_GEN_VERSION \
&& make get-deps \
&& make all
FROM nginx:1.19-alpine
LABEL maintainer="Nicolas Duchon <nicolas.duchon@gmail.com>"
# DOCKER_GEN_VERSION environment variable is required by acme-companion
ENV DOCKER_GEN_VERSION=0.7.4 \
DOCKER_HOST=unix:///tmp/docker.sock
# Install/update run dependencies
RUN apk add --update \
bash \
ca-certificates \
curl \
openssl \
&& rm -rf /var/cache/apk/*
# Configure Nginx and apply fix for very long server names
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
&& sed -i 's/worker_processes 1/worker_processes auto/' /etc/nginx/nginx.conf
# Copy forego and docker-gen binaries from build stage
COPY --from=go-builder /go/src/github.com/ddollar/forego/forego /usr/local/bin/
COPY --from=go-builder /go/src/github.com/jwilder/docker-gen/docker-gen /usr/local/bin/
# Install nginx-proxy
RUN mkdir /src /app \
&& curl -sSL https://github.com/nginx-proxy/nginx-proxy/archive/main.tar.gz \
| tar -C /src -xz \
&& cp /src/nginx-proxy-main/Procfile /app/ \
&& cp /src/nginx-proxy-main/dhparam.pem.default /app/ \
&& cp /src/nginx-proxy-main/docker-entrypoint.sh /app/ \
&& cp /src/nginx-proxy-main/generate-dhparam.sh /app/ \
&& cp /src/nginx-proxy-main/nginx.tmpl /app/ \
&& cp /src/nginx-proxy-main/network_internal.conf /etc/nginx/ \
&& rm -rf /src
WORKDIR /app
VOLUME ["/etc/nginx/certs", "/etc/nginx/dhparam"]
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["forego", "start", "-r"]