1
0
peddlers-of-ketran/Dockerfile.dev

32 lines
994 B
Docker

FROM node:20-alpine
# Build args for host UID/GID to create a matching user inside the image.
ARG HOST_UID=1000
ARG HOST_GID=1000
RUN apk add --no-cache sqlite shadow
WORKDIR /server
# Create host user/group and ensure /server is owned by them so mounted
# files appear with the desired ownership on the host.
RUN if ! getent group ${HOST_GID} >/dev/null 2>&1; then \
addgroup -g ${HOST_GID} hostgroup; \
else \
echo "group for GID ${HOST_GID} already exists"; \
fi
RUN if ! getent passwd ${HOST_UID} >/dev/null 2>&1; then \
adduser -D -u ${HOST_UID} -G hostgroup hostuser; \
else \
echo "user for UID ${HOST_UID} already exists"; \
mkdir -p /home/hostuser || true; \
fi
RUN chown -R ${HOST_UID}:${HOST_GID} /server || true
ENV HOME=/home/hostuser
USER ${HOST_UID}:${HOST_GID}
# For dev, we install in container at runtime since volumes mount.
CMD ["sh", "-c", "cd /server && npm install --no-audit --no-fund --silent && npm rebuild sqlite3 && npm run start:dev"]