wg-portal/Dockerfile

51 lines
1.5 KiB
Docker
Raw Normal View History

2020-11-10 03:57:49 -05:00
# Dockerfile References: https://docs.docker.com/engine/reference/builder/
# This dockerfile uses a multi-stage build system to reduce the image footprint.
######-
# Start from the latest golang base image as builder image (only used to compile the code)
######-
FROM golang:1.16 as builder
2020-11-10 03:57:49 -05:00
RUN mkdir /build
# Copy the source from the current directory to the Working Directory inside the container
ADD . /build/
# Set the Current Working Directory inside the container
WORKDIR /build
2020-11-10 05:59:02 -05:00
# Workaround for failing travis-ci builds
RUN rm -rf ~/go; rm -rf go.sum
2020-11-10 03:57:49 -05:00
# Build the Go app
2020-11-10 05:26:30 -05:00
RUN go clean -modcache; go mod tidy; make build
2020-11-10 03:57:49 -05:00
######-
# Here starts the main image
######-
FROM debian:buster
# Setup timezone
ENV TZ=Europe/Vienna
# GOSS for container health checks
ENV GOSS_VERSION v0.3.16
2020-11-10 03:57:49 -05:00
RUN apt-get update && apt-get upgrade -y && \
apt-get install --no-install-recommends -y moreutils ca-certificates curl && \
rm -rf /var/cache/apt /var/lib/apt/lists/*; \
curl -L https://github.com/aelsabbahy/goss/releases/download/$GOSS_VERSION/goss-linux-amd64 -o /usr/local/bin/goss && \
chmod +rx /usr/local/bin/goss && \
goss --version
2020-12-18 15:56:54 -05:00
COPY --from=builder /build/dist/wg-portal-amd64 /app/wgportal
2020-11-10 03:57:49 -05:00
COPY --from=builder /build/scripts /app/
# Set the Current Working Directory inside the container
WORKDIR /app
# Command to run the executable
2020-11-13 03:10:21 -05:00
CMD [ "/app/wgportal" ]
2020-11-10 03:57:49 -05:00
HEALTHCHECK --interval=1m --timeout=10s \
CMD /app/docker-healthcheck.sh