feat: ability to chose uid and gid on build

This commit is contained in:
Ravinou 2024-01-01 13:07:19 +01:00
parent 532d23973e
commit 006fa4862a
No known key found for this signature in database
GPG key ID: EEEE670C40F6A4D7
2 changed files with 10 additions and 6 deletions

View file

@ -1,5 +1,8 @@
FROM node:20-bookworm-slim as base
ARG UID=1001
ARG GID=1001
# build stage
FROM base AS deps
@ -31,9 +34,7 @@ RUN apt-get update && apt-get install -y \
curl jq jc borgbackup openssh-server sudo cron rsyslog && \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN groupadd borgwarehouse
RUN useradd -m -g borgwarehouse borgwarehouse
RUN groupadd -g ${GID} borgwarehouse && useradd -m -u ${UID} -g ${GID} borgwarehouse
RUN cp /etc/ssh/sshd_config /etc/ssh/moduli /home/borgwarehouse/

View file

@ -6,11 +6,14 @@ services:
#build:
# context: .
# dockerfile: Dockerfile
# args:
# - UID=${UID}
# - GID=${GID}
image: borgwarehouse/borgwarehouse
user: "${UID:?UID variable missing}:${GID:?GID variable missing}"
user: '${UID:?UID variable missing}:${GID:?GID variable missing}'
ports:
- "${WEB_SERVER_PORT:?WEB_SERVER_PORT variable missing}:3000"
- "${SSH_SERVER_PORT:?SSH_SERVER_PORT variable missing}:22"
- '${WEB_SERVER_PORT:?WEB_SERVER_PORT variable missing}:3000'
- '${SSH_SERVER_PORT:?SSH_SERVER_PORT variable missing}:22'
env_file:
- .env
volumes: