2020-07-10 14:26:03 +02:00
|
|
|
# setup build arguments for version of dependencies to use
|
|
|
|
ARG NGINX_VERSION=1.19.3-alpine
|
|
|
|
|
|
|
|
ARG DOCKER_GEN_VERSION=0.7.4
|
|
|
|
ARG FOREGO_VERSION=0.16.1
|
|
|
|
|
|
|
|
# Use a specific version of golang to build both binaries
|
2021-04-01 13:54:37 +02:00
|
|
|
FROM golang:1.15.10-alpine as gobuilder
|
2020-07-10 14:26:03 +02:00
|
|
|
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:$NGINX_VERSION
|
2017-10-31 18:21:12 -07:00
|
|
|
LABEL maintainer="Jason Wilder mail@jasonwilder.com"
|
2016-09-01 17:29:25 +02:00
|
|
|
|
|
|
|
# Install wget and install/updates certificates
|
|
|
|
RUN apk add --no-cache --virtual .run-deps \
|
2017-01-12 00:21:39 -05:00
|
|
|
ca-certificates bash wget openssl \
|
2016-09-01 17:29:25 +02:00
|
|
|
&& update-ca-certificates
|
|
|
|
|
2017-06-14 16:31:12 -06:00
|
|
|
|
2016-09-01 17:29:25 +02:00
|
|
|
# Configure Nginx and apply fix for very long server names
|
|
|
|
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
|
2017-06-13 09:11:27 +08:00
|
|
|
&& sed -i 's/worker_processes 1/worker_processes auto/' /etc/nginx/nginx.conf
|
2016-09-01 17:29:25 +02:00
|
|
|
|
2020-07-10 14:26:03 +02:00
|
|
|
# Install Forego + docker-gen
|
|
|
|
COPY --from=forego /go/src/github.com/ddollar/forego/forego /usr/local/bin/forego
|
|
|
|
COPY --from=dockergen /go/src/github.com/jwilder/docker-gen/docker-gen /usr/local/bin/docker-gen
|
2016-09-01 17:29:25 +02:00
|
|
|
|
2020-07-10 14:26:03 +02:00
|
|
|
# Add DOCKER_GEN_VERSION environment variable
|
|
|
|
# Because some external projects rely on it
|
|
|
|
ARG DOCKER_GEN_VERSION
|
|
|
|
ENV DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION}
|
2016-09-01 17:29:25 +02:00
|
|
|
|
2018-03-07 22:36:05 +01:00
|
|
|
COPY network_internal.conf /etc/nginx/
|
|
|
|
|
2016-09-01 17:29:25 +02:00
|
|
|
COPY . /app/
|
|
|
|
WORKDIR /app/
|
|
|
|
|
|
|
|
ENV DOCKER_HOST unix:///tmp/docker.sock
|
|
|
|
|
2017-01-11 23:04:24 -05:00
|
|
|
VOLUME ["/etc/nginx/certs", "/etc/nginx/dhparam"]
|
2016-09-01 17:29:25 +02:00
|
|
|
|
|
|
|
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
|
|
|
CMD ["forego", "start", "-r"]
|