Skip to content

Commit

Permalink
Add UID/GID build args to docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
DocDvorak committed Nov 12, 2024
1 parent 702832d commit dceff4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@ RUN CGO_ENABLED=0 \
go build -o screeps-launcher ./cmd/screeps-launcher

FROM buildpack-deps:buster
RUN groupadd --gid 1000 screeps \
&& useradd --uid 1000 --gid screeps --shell /bin/bash --create-home screeps \
&& mkdir /screeps && chown screeps.screeps /screeps
USER screeps

ARG UID=1000
ARG GID=1000
RUN <<-EOT bash
if [[ "${GID}" != "0" ]] ; then
groupadd --gid ${GID} screeps
fi
if [[ "${UID}" != "0" ]] ; then
useradd --uid ${UID} --gid ${GID} --shell /bin/bash --create-home screeps
fi
mkdir /screeps && chown ${UID}:${GID} /screeps
EOT

USER ${UID}:${GID}
VOLUME /screeps
WORKDIR /screeps
COPY --from=builder /app/screeps-launcher /usr/bin/
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
context: .
args:
ARCH: amd64
UID: 1000
GID: 1000
image: screepers/screeps-launcher
volumes:
- ./config.yml:/screeps/config.yml
Expand Down

0 comments on commit dceff4f

Please sign in to comment.