2020-11-10 08:57:49 +00: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)
|
|
|
|
######-
|
2023-10-26 10:42:18 +00:00
|
|
|
FROM golang:1.21 as builder
|
2020-11-10 08:57:49 +00:00
|
|
|
|
2021-04-08 07:23:48 +00:00
|
|
|
ARG BUILD_IDENTIFIER
|
|
|
|
ENV ENV_BUILD_IDENTIFIER=$BUILD_IDENTIFIER
|
|
|
|
|
|
|
|
ARG BUILD_VERSION
|
|
|
|
ENV ENV_BUILD_VERSION=$BUILD_VERSION
|
|
|
|
|
2022-11-11 16:10:41 +00:00
|
|
|
# populated by BuildKit
|
|
|
|
ARG TARGETPLATFORM
|
|
|
|
ENV ENV_TARGETPLATFORM=$TARGETPLATFORM
|
|
|
|
|
2020-11-10 08:57:49 +00: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
|
|
|
|
|
|
|
|
# Build the Go app
|
2022-11-11 16:10:41 +00:00
|
|
|
RUN echo "Building version '$ENV_BUILD_IDENTIFIER-$ENV_BUILD_VERSION' for platform $ENV_TARGETPLATFORM"; make build
|
2020-11-10 08:57:49 +00:00
|
|
|
|
|
|
|
######-
|
|
|
|
# Here starts the main image
|
|
|
|
######-
|
2021-04-08 07:23:48 +00:00
|
|
|
FROM scratch
|
2020-11-10 08:57:49 +00:00
|
|
|
|
|
|
|
# Setup timezone
|
|
|
|
ENV TZ=Europe/Vienna
|
|
|
|
|
2021-04-08 07:23:48 +00:00
|
|
|
# Import linux stuff from builder.
|
|
|
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
|
|
|
COPY --from=builder /etc/passwd /etc/passwd
|
|
|
|
COPY --from=builder /etc/group /etc/group
|
|
|
|
|
|
|
|
# Copy binaries
|
2022-11-11 16:10:41 +00:00
|
|
|
COPY --from=builder /build/dist/wg-portal /app/wg-portal
|
2020-11-10 08:57:49 +00:00
|
|
|
|
|
|
|
# Set the Current Working Directory inside the container
|
|
|
|
WORKDIR /app
|
|
|
|
|
2023-10-26 10:42:18 +00:00
|
|
|
# by default, the web-portal is reachable on port 8888
|
|
|
|
EXPOSE 8888/tcp
|
|
|
|
|
|
|
|
# the database and config file can be mounted from the host
|
|
|
|
VOLUME [ "/app/data", "/app/config" ]
|
|
|
|
|
2020-11-10 08:57:49 +00:00
|
|
|
# Command to run the executable
|
2023-10-26 10:42:18 +00:00
|
|
|
ENTRYPOINT [ "/app/wg-portal" ]
|