2020-07-10 14:26:03 +02:00
|
|
|
# setup build arguments for version of dependencies to use
|
2022-02-24 16:21:10 +01:00
|
|
|
ARG DOCKER_GEN_VERSION=0.8.2
|
2021-04-27 00:56:47 +02:00
|
|
|
ARG FOREGO_VERSION=v0.17.0
|
2020-07-10 14:26:03 +02:00
|
|
|
|
|
|
|
# Use a specific version of golang to build both binaries
|
2021-08-06 04:11:55 +00:00
|
|
|
FROM golang:1.16.7 as gobuilder
|
2020-07-10 14:26:03 +02:00
|
|
|
|
|
|
|
# Build docker-gen from scratch
|
|
|
|
FROM gobuilder as dockergen
|
|
|
|
|
|
|
|
ARG DOCKER_GEN_VERSION
|
|
|
|
|
2022-01-11 19:55:29 +01:00
|
|
|
RUN git clone https://github.com/nginx-proxy/docker-gen \
|
2021-04-26 14:55:33 +02:00
|
|
|
&& 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
|
2020-07-10 14:26:03 +02:00
|
|
|
|
|
|
|
# Build forego from scratch
|
|
|
|
FROM gobuilder as forego
|
|
|
|
|
|
|
|
ARG FOREGO_VERSION
|
|
|
|
|
2021-04-27 00:56:47 +02:00
|
|
|
RUN git clone https://github.com/nginx-proxy/forego/ \
|
|
|
|
&& cd /go/forego \
|
|
|
|
&& git -c advice.detachedHead=false checkout $FOREGO_VERSION \
|
|
|
|
&& go mod download \
|
|
|
|
&& CGO_ENABLED=0 GOOS=linux go build -o forego . \
|
|
|
|
&& go clean -cache \
|
|
|
|
&& mv forego /usr/local/bin/ \
|
|
|
|
&& cd - \
|
|
|
|
&& rm -rf /go/forego
|
2020-07-10 14:26:03 +02:00
|
|
|
|
|
|
|
# Build the final image
|
2022-01-26 04:07:38 +00:00
|
|
|
FROM nginx:1.21.6
|
2014-05-05 10:59:23 -06:00
|
|
|
|
2022-01-11 22:38:30 +01:00
|
|
|
ARG NGINX_PROXY_VERSION
|
|
|
|
# Add DOCKER_GEN_VERSION environment variable
|
|
|
|
# Because some external projects rely on it
|
|
|
|
ARG DOCKER_GEN_VERSION
|
|
|
|
ENV NGINX_PROXY_VERSION=${NGINX_PROXY_VERSION} \
|
|
|
|
DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION} \
|
|
|
|
DOCKER_HOST=unix:///tmp/docker.sock
|
|
|
|
|
2014-11-26 23:53:35 +01:00
|
|
|
# Install wget and install/updates certificates
|
|
|
|
RUN apt-get update \
|
2021-08-04 08:49:23 +02:00
|
|
|
&& apt-get install -y -q --no-install-recommends \
|
|
|
|
ca-certificates \
|
|
|
|
wget \
|
|
|
|
&& apt-get clean \
|
|
|
|
&& rm -r /var/lib/apt/lists/*
|
2014-11-22 19:42:54 +01:00
|
|
|
|
2017-06-14 16:31:12 -06:00
|
|
|
|
2015-01-02 10:45:40 +06:30
|
|
|
# Configure Nginx and apply fix for very long server names
|
2014-11-22 19:42:54 +01:00
|
|
|
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
2021-08-04 08:49:23 +02:00
|
|
|
&& sed -i 's/worker_processes 1/worker_processes auto/' /etc/nginx/nginx.conf \
|
2021-09-28 11:14:46 +13:00
|
|
|
&& sed -i 's/worker_connections 1024/worker_connections 10240/' /etc/nginx/nginx.conf \
|
|
|
|
&& mkdir -p '/etc/nginx/dhparam'
|
2014-11-22 19:42:54 +01:00
|
|
|
|
2020-07-10 14:26:03 +02:00
|
|
|
# Install Forego + docker-gen
|
2021-04-27 00:56:47 +02:00
|
|
|
COPY --from=forego /usr/local/bin/forego /usr/local/bin/forego
|
2021-04-26 14:55:33 +02:00
|
|
|
COPY --from=dockergen /usr/local/bin/docker-gen /usr/local/bin/docker-gen
|
2014-06-08 01:23:16 +05:30
|
|
|
|
2017-10-18 12:57:59 -04:00
|
|
|
COPY network_internal.conf /etc/nginx/
|
|
|
|
|
2014-11-22 19:42:54 +01:00
|
|
|
COPY . /app/
|
|
|
|
WORKDIR /app/
|
2014-09-17 19:37:39 +01:00
|
|
|
|
2015-09-11 22:05:54 +00:00
|
|
|
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
2015-09-12 07:18:12 -07:00
|
|
|
CMD ["forego", "start", "-r"]
|