2
0

Dockerfile.alpine 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # setup build arguments for version of dependencies to use
  2. ARG DOCKER_GEN_VERSION=0.7.4
  3. ARG FOREGO_VERSION=0.16.1
  4. # Use a specific version of golang to build both binaries
  5. FROM golang:1.15.10-alpine as gobuilder
  6. RUN apk add --no-cache git
  7. # Build docker-gen from scratch
  8. FROM gobuilder as dockergen
  9. # Download the sources for the given version
  10. ARG DOCKER_GEN_VERSION
  11. ADD https://github.com/jwilder/docker-gen/archive/${DOCKER_GEN_VERSION}.tar.gz sources.tar.gz
  12. # Move the sources into the right directory
  13. RUN tar -xzf sources.tar.gz && \
  14. mkdir -p /go/src/github.com/jwilder/ && \
  15. mv docker-gen-* /go/src/github.com/jwilder/docker-gen
  16. # Install the dependencies and make the docker-gen executable
  17. WORKDIR /go/src/github.com/jwilder/docker-gen
  18. RUN go get -v ./... && \
  19. CGO_ENABLED=0 GOOS=linux go build -ldflags "-X main.buildVersion=${DOCKER_GEN_VERSION}" ./cmd/docker-gen
  20. # Build forego from scratch
  21. # Because this relies on golang workspaces, we need to use go < 1.8.
  22. FROM gobuilder as forego
  23. # Download the sources for the given version
  24. ARG FOREGO_VERSION
  25. ADD https://github.com/jwilder/forego/archive/v${FOREGO_VERSION}.tar.gz sources.tar.gz
  26. # Move the sources into the right directory
  27. RUN tar -xzf sources.tar.gz && \
  28. mkdir -p /go/src/github.com/ddollar/ && \
  29. mv forego-* /go/src/github.com/ddollar/forego
  30. # Install the dependencies and make the forego executable
  31. WORKDIR /go/src/github.com/ddollar/forego/
  32. RUN go get -v ./... && \
  33. CGO_ENABLED=0 GOOS=linux go build -o forego .
  34. # Build the final image
  35. FROM nginx:1.19.3-alpine
  36. LABEL maintainer="Jason Wilder mail@jasonwilder.com"
  37. # Install wget and install/updates certificates
  38. RUN apk add --no-cache --virtual .run-deps \
  39. ca-certificates bash wget openssl \
  40. && update-ca-certificates
  41. # Configure Nginx and apply fix for very long server names
  42. RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
  43. && sed -i 's/worker_processes 1/worker_processes auto/' /etc/nginx/nginx.conf
  44. # Install Forego + docker-gen
  45. COPY --from=forego /go/src/github.com/ddollar/forego/forego /usr/local/bin/forego
  46. COPY --from=dockergen /go/src/github.com/jwilder/docker-gen/docker-gen /usr/local/bin/docker-gen
  47. # Add DOCKER_GEN_VERSION environment variable
  48. # Because some external projects rely on it
  49. ARG DOCKER_GEN_VERSION
  50. ENV DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION}
  51. COPY network_internal.conf /etc/nginx/
  52. COPY . /app/
  53. WORKDIR /app/
  54. ENV DOCKER_HOST unix:///tmp/docker.sock
  55. VOLUME ["/etc/nginx/certs", "/etc/nginx/dhparam"]
  56. ENTRYPOINT ["/app/docker-entrypoint.sh"]
  57. CMD ["forego", "start", "-r"]