mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 01:38:15 +00:00
build: get docker-gen from pre-built image (#2230)
* build: get docker-gen from pre-built image * build: requested changes
This commit is contained in:
parent
c337a13847
commit
0501c54002
26
.github/workflows/build-publish.yml
vendored
26
.github/workflows/build-publish.yml
vendored
@ -28,8 +28,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Retrieve version
|
- name: Retrieve nginx-proxy version
|
||||||
run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV
|
id: nginx-proxy_version
|
||||||
|
run: echo "VERSION=$(git describe --tags)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Get Docker tags for Debian based image
|
- name: Get Docker tags for Debian based image
|
||||||
id: docker_meta_debian
|
id: docker_meta_debian
|
||||||
@ -66,13 +67,19 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Retrieve docker-gen version
|
||||||
|
id: docker-gen_version
|
||||||
|
run: sed -n -e 's;^FROM nginxproxy/docker-gen:\([0-9.]*\).*;VERSION=\1;p' Dockerfile >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Build and push the Debian based image
|
- name: Build and push the Debian based image
|
||||||
id: docker_build_debian
|
id: docker_build_debian
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
build-args: NGINX_PROXY_VERSION=${{ env.GIT_DESCRIBE }}
|
build-args: |
|
||||||
|
NGINX_PROXY_VERSION=${{ steps.nginx-proxy_version.outputs.VERSION }}
|
||||||
|
DOCKER_GEN_VERSION=${{ steps.docker-gen_version.outputs.VERSION }}
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.docker_meta_debian.outputs.tags }}
|
tags: ${{ steps.docker_meta_debian.outputs.tags }}
|
||||||
@ -90,8 +97,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Retrieve version
|
- name: Retrieve nginx-proxy version
|
||||||
run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV
|
id: nginx-proxy_version
|
||||||
|
run: echo "VERSION=$(git describe --tags)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Get Docker tags for Alpine based image
|
- name: Get Docker tags for Alpine based image
|
||||||
id: docker_meta_alpine
|
id: docker_meta_alpine
|
||||||
@ -129,13 +137,19 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Retrieve docker-gen version
|
||||||
|
id: docker-gen_version
|
||||||
|
run: sed -n -e 's;^FROM nginxproxy/docker-gen:\([0-9.]*\).*;VERSION=\1;p' Dockerfile >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Build and push the Alpine based image
|
- name: Build and push the Alpine based image
|
||||||
id: docker_build_alpine
|
id: docker_build_alpine
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile.alpine
|
file: Dockerfile.alpine
|
||||||
build-args: NGINX_PROXY_VERSION=${{ env.GIT_DESCRIBE }}
|
build-args: |
|
||||||
|
NGINX_PROXY_VERSION=${{ steps.nginx-proxy_version.outputs.VERSION }}
|
||||||
|
DOCKER_GEN_VERSION=${{ steps.docker-gen_version.outputs.VERSION }}
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.docker_meta_alpine.outputs.tags }}
|
tags: ${{ steps.docker_meta_alpine.outputs.tags }}
|
||||||
|
29
Dockerfile
29
Dockerfile
@ -1,27 +1,10 @@
|
|||||||
# setup build arguments for version of dependencies to use
|
# setup build arguments for version of dependencies to use
|
||||||
ARG DOCKER_GEN_VERSION=0.10.4
|
|
||||||
ARG FOREGO_VERSION=v0.17.0
|
ARG FOREGO_VERSION=v0.17.0
|
||||||
|
|
||||||
# Use a specific version of golang to build both binaries
|
FROM nginxproxy/docker-gen:0.10.4-debian AS docker-gen
|
||||||
FROM golang:1.20.3 as gobuilder
|
|
||||||
|
|
||||||
# Build docker-gen from scratch
|
|
||||||
FROM gobuilder as dockergen
|
|
||||||
|
|
||||||
ARG DOCKER_GEN_VERSION
|
|
||||||
|
|
||||||
RUN git clone https://github.com/nginx-proxy/docker-gen \
|
|
||||||
&& cd /go/docker-gen \
|
|
||||||
&& git -c advice.detachedHead=false checkout $DOCKER_GEN_VERSION \
|
|
||||||
&& go mod download \
|
|
||||||
&& CGO_ENABLED=0 GOOS=linux go build -ldflags "-X main.buildVersion=${DOCKER_GEN_VERSION}" ./cmd/docker-gen \
|
|
||||||
&& go clean -cache \
|
|
||||||
&& mv docker-gen /usr/local/bin/ \
|
|
||||||
&& cd - \
|
|
||||||
&& rm -rf /go/docker-gen
|
|
||||||
|
|
||||||
# Build forego from scratch
|
# Build forego from scratch
|
||||||
FROM gobuilder as forego
|
FROM golang:1.20.3 as forego
|
||||||
|
|
||||||
ARG FOREGO_VERSION
|
ARG FOREGO_VERSION
|
||||||
|
|
||||||
@ -39,9 +22,9 @@ RUN git clone https://github.com/nginx-proxy/forego/ \
|
|||||||
FROM nginx:1.23.4
|
FROM nginx:1.23.4
|
||||||
|
|
||||||
ARG NGINX_PROXY_VERSION
|
ARG NGINX_PROXY_VERSION
|
||||||
# Add DOCKER_GEN_VERSION environment variable
|
# Add DOCKER_GEN_VERSION environment variable because
|
||||||
# Because some external projects rely on it
|
# acme-companion rely on it (but the actual value is not important)
|
||||||
ARG DOCKER_GEN_VERSION
|
ARG DOCKER_GEN_VERSION="unknown"
|
||||||
ENV NGINX_PROXY_VERSION=${NGINX_PROXY_VERSION} \
|
ENV NGINX_PROXY_VERSION=${NGINX_PROXY_VERSION} \
|
||||||
DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION} \
|
DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION} \
|
||||||
DOCKER_HOST=unix:///tmp/docker.sock
|
DOCKER_HOST=unix:///tmp/docker.sock
|
||||||
@ -63,7 +46,7 @@ RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
|||||||
|
|
||||||
# Install Forego + docker-gen
|
# Install Forego + docker-gen
|
||||||
COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego
|
COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego
|
||||||
COPY --from=dockergen /usr/local/bin/docker-gen /usr/local/bin/docker-gen
|
COPY --from=docker-gen /usr/local/bin/docker-gen /usr/local/bin/docker-gen
|
||||||
|
|
||||||
COPY network_internal.conf /etc/nginx/
|
COPY network_internal.conf /etc/nginx/
|
||||||
|
|
||||||
|
@ -1,32 +1,15 @@
|
|||||||
# setup build arguments for version of dependencies to use
|
# setup build arguments for version of dependencies to use
|
||||||
ARG DOCKER_GEN_VERSION=0.10.4
|
|
||||||
ARG FOREGO_VERSION=v0.17.0
|
ARG FOREGO_VERSION=v0.17.0
|
||||||
|
|
||||||
# Use a specific version of golang to build both binaries
|
FROM nginxproxy/docker-gen:0.10.4 AS docker-gen
|
||||||
FROM golang:1.20.3-alpine as gobuilder
|
|
||||||
RUN apk add --no-cache git musl-dev
|
|
||||||
|
|
||||||
# Build docker-gen from scratch
|
|
||||||
FROM gobuilder as dockergen
|
|
||||||
|
|
||||||
ARG DOCKER_GEN_VERSION
|
|
||||||
|
|
||||||
RUN git clone https://github.com/nginx-proxy/docker-gen \
|
|
||||||
&& cd /go/docker-gen \
|
|
||||||
&& git -c advice.detachedHead=false checkout $DOCKER_GEN_VERSION \
|
|
||||||
&& go mod download \
|
|
||||||
&& CGO_ENABLED=0 go build -ldflags "-X main.buildVersion=${DOCKER_GEN_VERSION}" ./cmd/docker-gen \
|
|
||||||
&& go clean -cache \
|
|
||||||
&& mv docker-gen /usr/local/bin/ \
|
|
||||||
&& cd - \
|
|
||||||
&& rm -rf /go/docker-gen
|
|
||||||
|
|
||||||
# Build forego from scratch
|
# Build forego from scratch
|
||||||
FROM gobuilder as forego
|
FROM golang:1.20.3-alpine as forego
|
||||||
|
|
||||||
ARG FOREGO_VERSION
|
ARG FOREGO_VERSION
|
||||||
|
|
||||||
RUN git clone https://github.com/nginx-proxy/forego/ \
|
RUN apk add --no-cache git musl-dev \
|
||||||
|
&& git clone https://github.com/nginx-proxy/forego/ \
|
||||||
&& cd /go/forego \
|
&& cd /go/forego \
|
||||||
&& git -c advice.detachedHead=false checkout $FOREGO_VERSION \
|
&& git -c advice.detachedHead=false checkout $FOREGO_VERSION \
|
||||||
&& go mod download \
|
&& go mod download \
|
||||||
@ -40,9 +23,9 @@ RUN git clone https://github.com/nginx-proxy/forego/ \
|
|||||||
FROM nginx:1.23.4-alpine
|
FROM nginx:1.23.4-alpine
|
||||||
|
|
||||||
ARG NGINX_PROXY_VERSION
|
ARG NGINX_PROXY_VERSION
|
||||||
# Add DOCKER_GEN_VERSION environment variable
|
# Add DOCKER_GEN_VERSION environment variable because
|
||||||
# Because some external projects rely on it
|
# acme-companion rely on it (but the actual value is not important)
|
||||||
ARG DOCKER_GEN_VERSION
|
ARG DOCKER_GEN_VERSION="unknown"
|
||||||
ENV NGINX_PROXY_VERSION=${NGINX_PROXY_VERSION} \
|
ENV NGINX_PROXY_VERSION=${NGINX_PROXY_VERSION} \
|
||||||
DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION} \
|
DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION} \
|
||||||
DOCKER_HOST=unix:///tmp/docker.sock
|
DOCKER_HOST=unix:///tmp/docker.sock
|
||||||
@ -60,7 +43,7 @@ RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
|||||||
|
|
||||||
# Install Forego + docker-gen
|
# Install Forego + docker-gen
|
||||||
COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego
|
COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego
|
||||||
COPY --from=dockergen /usr/local/bin/docker-gen /usr/local/bin/docker-gen
|
COPY --from=docker-gen /usr/local/bin/docker-gen /usr/local/bin/docker-gen
|
||||||
|
|
||||||
COPY network_internal.conf /etc/nginx/
|
COPY network_internal.conf /etc/nginx/
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user