mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 09:48:14 +00:00
Merge pull request #1470 from KWARC/build-from-scratch
Enable multi-architecture docker image builds
This commit is contained in:
commit
65b44f0ca2
58
Dockerfile
58
Dockerfile
@ -1,3 +1,46 @@
|
|||||||
|
# setup build arguments for version of dependencies to use
|
||||||
|
ARG DOCKER_GEN_VERSION=0.7.4
|
||||||
|
ARG FOREGO_VERSION=0.16.1
|
||||||
|
|
||||||
|
# Use a specific version of golang to build both binaries
|
||||||
|
FROM golang:1.15.10 as gobuilder
|
||||||
|
|
||||||
|
# Build docker-gen from scratch
|
||||||
|
FROM gobuilder as dockergen
|
||||||
|
|
||||||
|
# Download the sources for the given version
|
||||||
|
ARG DOCKER_GEN_VERSION
|
||||||
|
ADD https://github.com/jwilder/docker-gen/archive/${DOCKER_GEN_VERSION}.tar.gz sources.tar.gz
|
||||||
|
|
||||||
|
# Move the sources into the right directory
|
||||||
|
RUN tar -xzf sources.tar.gz && \
|
||||||
|
mkdir -p /go/src/github.com/jwilder/ && \
|
||||||
|
mv docker-gen-* /go/src/github.com/jwilder/docker-gen
|
||||||
|
|
||||||
|
# Install the dependencies and make the docker-gen executable
|
||||||
|
WORKDIR /go/src/github.com/jwilder/docker-gen
|
||||||
|
RUN go get -v ./... && \
|
||||||
|
CGO_ENABLED=0 GOOS=linux go build -ldflags "-X main.buildVersion=${DOCKER_GEN_VERSION}" ./cmd/docker-gen
|
||||||
|
|
||||||
|
# Build forego from scratch
|
||||||
|
# Because this relies on golang workspaces, we need to use go < 1.8.
|
||||||
|
FROM gobuilder as forego
|
||||||
|
|
||||||
|
# Download the sources for the given version
|
||||||
|
ARG FOREGO_VERSION
|
||||||
|
ADD https://github.com/jwilder/forego/archive/v${FOREGO_VERSION}.tar.gz sources.tar.gz
|
||||||
|
|
||||||
|
# Move the sources into the right directory
|
||||||
|
RUN tar -xzf sources.tar.gz && \
|
||||||
|
mkdir -p /go/src/github.com/ddollar/ && \
|
||||||
|
mv forego-* /go/src/github.com/ddollar/forego
|
||||||
|
|
||||||
|
# Install the dependencies and make the forego executable
|
||||||
|
WORKDIR /go/src/github.com/ddollar/forego/
|
||||||
|
RUN go get -v ./... && \
|
||||||
|
CGO_ENABLED=0 GOOS=linux go build -o forego .
|
||||||
|
|
||||||
|
# Build the final image
|
||||||
FROM nginx:1.19.3
|
FROM nginx:1.19.3
|
||||||
LABEL maintainer="Jason Wilder mail@jasonwilder.com"
|
LABEL maintainer="Jason Wilder mail@jasonwilder.com"
|
||||||
|
|
||||||
@ -14,15 +57,14 @@ RUN apt-get update \
|
|||||||
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
||||||
&& sed -i 's/worker_processes 1/worker_processes auto/' /etc/nginx/nginx.conf
|
&& sed -i 's/worker_processes 1/worker_processes auto/' /etc/nginx/nginx.conf
|
||||||
|
|
||||||
# Install Forego
|
# Install Forego + docker-gen
|
||||||
ADD https://github.com/jwilder/forego/releases/download/v0.16.1/forego /usr/local/bin/forego
|
COPY --from=forego /go/src/github.com/ddollar/forego/forego /usr/local/bin/forego
|
||||||
RUN chmod u+x /usr/local/bin/forego
|
COPY --from=dockergen /go/src/github.com/jwilder/docker-gen/docker-gen /usr/local/bin/docker-gen
|
||||||
|
|
||||||
ENV DOCKER_GEN_VERSION 0.7.4
|
# Add DOCKER_GEN_VERSION environment variable
|
||||||
|
# Because some external projects rely on it
|
||||||
RUN wget https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
|
ARG DOCKER_GEN_VERSION
|
||||||
&& tar -C /usr/local/bin -xvzf docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
|
ENV DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION}
|
||||||
&& rm /docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz
|
|
||||||
|
|
||||||
COPY network_internal.conf /etc/nginx/
|
COPY network_internal.conf /etc/nginx/
|
||||||
|
|
||||||
|
@ -1,3 +1,47 @@
|
|||||||
|
# setup build arguments for version of dependencies to use
|
||||||
|
ARG DOCKER_GEN_VERSION=0.7.4
|
||||||
|
ARG FOREGO_VERSION=0.16.1
|
||||||
|
|
||||||
|
# Use a specific version of golang to build both binaries
|
||||||
|
FROM golang:1.15.10-alpine as gobuilder
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
|
||||||
|
# Build docker-gen from scratch
|
||||||
|
FROM gobuilder as dockergen
|
||||||
|
|
||||||
|
# Download the sources for the given version
|
||||||
|
ARG DOCKER_GEN_VERSION
|
||||||
|
ADD https://github.com/jwilder/docker-gen/archive/${DOCKER_GEN_VERSION}.tar.gz sources.tar.gz
|
||||||
|
|
||||||
|
# Move the sources into the right directory
|
||||||
|
RUN tar -xzf sources.tar.gz && \
|
||||||
|
mkdir -p /go/src/github.com/jwilder/ && \
|
||||||
|
mv docker-gen-* /go/src/github.com/jwilder/docker-gen
|
||||||
|
|
||||||
|
# Install the dependencies and make the docker-gen executable
|
||||||
|
WORKDIR /go/src/github.com/jwilder/docker-gen
|
||||||
|
RUN go get -v ./... && \
|
||||||
|
CGO_ENABLED=0 GOOS=linux go build -ldflags "-X main.buildVersion=${DOCKER_GEN_VERSION}" ./cmd/docker-gen
|
||||||
|
|
||||||
|
# Build forego from scratch
|
||||||
|
# Because this relies on golang workspaces, we need to use go < 1.8.
|
||||||
|
FROM gobuilder as forego
|
||||||
|
|
||||||
|
# Download the sources for the given version
|
||||||
|
ARG FOREGO_VERSION
|
||||||
|
ADD https://github.com/jwilder/forego/archive/v${FOREGO_VERSION}.tar.gz sources.tar.gz
|
||||||
|
|
||||||
|
# Move the sources into the right directory
|
||||||
|
RUN tar -xzf sources.tar.gz && \
|
||||||
|
mkdir -p /go/src/github.com/ddollar/ && \
|
||||||
|
mv forego-* /go/src/github.com/ddollar/forego
|
||||||
|
|
||||||
|
# Install the dependencies and make the forego executable
|
||||||
|
WORKDIR /go/src/github.com/ddollar/forego/
|
||||||
|
RUN go get -v ./... && \
|
||||||
|
CGO_ENABLED=0 GOOS=linux go build -o forego .
|
||||||
|
|
||||||
|
# Build the final image
|
||||||
FROM nginx:1.19.3-alpine
|
FROM nginx:1.19.3-alpine
|
||||||
LABEL maintainer="Jason Wilder mail@jasonwilder.com"
|
LABEL maintainer="Jason Wilder mail@jasonwilder.com"
|
||||||
|
|
||||||
@ -11,15 +55,14 @@ RUN apk add --no-cache --virtual .run-deps \
|
|||||||
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
||||||
&& sed -i 's/worker_processes 1/worker_processes auto/' /etc/nginx/nginx.conf
|
&& sed -i 's/worker_processes 1/worker_processes auto/' /etc/nginx/nginx.conf
|
||||||
|
|
||||||
# Install Forego
|
# Install Forego + docker-gen
|
||||||
ADD https://github.com/jwilder/forego/releases/download/v0.16.1/forego /usr/local/bin/forego
|
COPY --from=forego /go/src/github.com/ddollar/forego/forego /usr/local/bin/forego
|
||||||
RUN chmod u+x /usr/local/bin/forego
|
COPY --from=dockergen /go/src/github.com/jwilder/docker-gen/docker-gen /usr/local/bin/docker-gen
|
||||||
|
|
||||||
ENV DOCKER_GEN_VERSION 0.7.4
|
# Add DOCKER_GEN_VERSION environment variable
|
||||||
|
# Because some external projects rely on it
|
||||||
RUN wget --quiet https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-alpine-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
|
ARG DOCKER_GEN_VERSION
|
||||||
&& tar -C /usr/local/bin -xvzf docker-gen-alpine-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
|
ENV DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION}
|
||||||
&& rm /docker-gen-alpine-linux-amd64-$DOCKER_GEN_VERSION.tar.gz
|
|
||||||
|
|
||||||
COPY network_internal.conf /etc/nginx/
|
COPY network_internal.conf /etc/nginx/
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user