From 44341353cda63cccfe324314e659decd10ced514 Mon Sep 17 00:00:00 2001 From: Benoit Donneaux Date: Fri, 31 May 2024 18:47:02 +0200 Subject: [PATCH] Add Dockerfile to build an image with Go support Signed-off-by: Benoit Donneaux --- docker/go/Dockerfile | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 docker/go/Dockerfile diff --git a/docker/go/Dockerfile b/docker/go/Dockerfile new file mode 100644 index 0000000..ef7e057 --- /dev/null +++ b/docker/go/Dockerfile @@ -0,0 +1,40 @@ +# Start from the official Go image based on Alpine +FROM golang:1.19.3-alpine + +LABEL Description="Trac2Gitea migration tool" + +RUN apk --no-cache add gcc libc-dev make + +# Parameters for default user:group +ARG uid=1000 +ARG user=appuser +ARG gid=1000 +ARG group=appgroup + +# Add user and group for build and runtime +RUN id ${user} > /dev/null 2>&1 || \ + { addgroup -g "${gid}" "${group}" && adduser -D -h /home/${user} -s /bin/bash -G "${group}" -u "${uid}" "${user}"; } + +# Prepare directories +RUN DIRS="/src /app" && \ + mkdir -p ${DIRS} && \ + chown -R ${user}:${group} $DIRS + +# Switch to non-root user +USER ${user} + +# Inject the source code +#COPY *.go go.* accessor/* importer log markdown /src/ + +# Download deps, build the app and cleanup the source +WORKDIR /src +#RUN go mod download && \ +# go mod verify + +#RUN go build -o /app/trac2gitea -ldflags '-extldflags "-static"' -buildvcs=false -v + +# Switch to app directory +#WORKDIR /app + +# Run the app by default +#CMD ./trac2gitea