nonroot user (ui container)

This commit is contained in:
Jörn-Michael Miehe 2020-09-07 15:29:02 +02:00
parent d47069cef2
commit 2c90b87818
2 changed files with 23 additions and 1 deletions

View file

@ -4,8 +4,13 @@ volumes:
frontend_home: frontend_home:
services: services:
# Frontend
ui: ui:
build: ui/docker build:
context: ui/docker
args:
NONROOT_UID: 1000
NONROOT_GID: 1000
restart: 'unless-stopped' restart: 'unless-stopped'
volumes: volumes:
- "frontend_home:/home/node" - "frontend_home:/home/node"
@ -13,10 +18,12 @@ services:
ports: ports:
- 8000:8000 - 8000:8000
# Backend
api: api:
build: api build: api
restart: 'no' restart: 'no'
# Common Proxy
dev-proxy: dev-proxy:
build: dev-proxy build: dev-proxy
restart: 'no' restart: 'no'

View file

@ -1,13 +1,28 @@
FROM node:lts-alpine FROM node:lts-alpine
LABEL maintainer="joern-michael.miehe@lenaisten.de" LABEL maintainer="joern-michael.miehe@lenaisten.de"
# vue services directory
WORKDIR /srv/vue WORKDIR /srv/vue
# install vue cli
RUN set -ex; \ RUN set -ex; \
yarn global add @vue/cli yarn global add @vue/cli
# user setup
ARG NONROOT_UID=1000
ARG NONROOT_GID=1000
# recycle node user
RUN set -ex; \
deluser --remove-home node; \
addgroup -g ${NONROOT_GID} node; \
adduser --disabled-password --gecos '' --uid "${NONROOT_UID}" --ingroup node node
# user change
USER node USER node
# persistent home directory
VOLUME [ "/home/node" ] VOLUME [ "/home/node" ]
# run vue ui
CMD [ "vue", "ui", "-H", "0.0.0.0" ] CMD [ "vue", "ui", "-H", "0.0.0.0" ]