From 0af5f2f141f43d143cecfaf5bb33906210a678e4 Mon Sep 17 00:00:00 2001 From: Ashlie Martinez Date: Tue, 3 May 2022 15:31:23 -0700 Subject: [PATCH] Very basic golang docker with new user. * Expects go get/go mod to be used to handle application dependencies * Expects users to use a volume mount to make code visible to the container * Add a user (with the option of having the same UID/GID as current user) to avoid weird file owners when building things in the container as golang usually runs as root --- docker/Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 docker/Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..b74c2b405 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.18 + +ARG uid=1000 +ARG gid=1000 + +# Dockerfile with static deps that won't be changed. Right now there's no deps +# outside of what the go.mod file has to manage. Makes a user in the container +# with the same UID and GID as the current user so that the mounted directory +# doesn't end up with files with strange permissions. + +RUN groupadd -g "${gid}" build && \ + useradd -m -u "${uid}" -g "${gid}" build + +USER build:build