Run as rootless user & improve build cache

pull/126/head
Zusier 3 years ago committed by GitHub
parent 8b0bfd6a58
commit 8560efd2eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,14 +9,14 @@ FROM node:16.14.0
# Set working directory # Set working directory
WORKDIR /opt/ass/ WORKDIR /opt/ass/
# Copy directory files (config.json, source files etc.) # create rootless user with uid/gid as 1000
COPY . ./ RUN groupadd -g 1000 -o ass && useradd -m -u 1000 -g 1000 -o -s /bin/bash ass
# Update npm to at least npm 8, # Set permissions for rootless user
# then install dependencies RUN chown -R ass /opt/ass/ && chmod -R 774 /opt/ass/
RUN npm i -g npm@8 typescript && \
npm i --save-dev && \ # run container as previously created user
npm run build USER ass
# Ensure these directories & files exist for compose volumes # Ensure these directories & files exist for compose volumes
RUN mkdir -p /opt/ass/uploads/thumbnails/ && \ RUN mkdir -p /opt/ass/uploads/thumbnails/ && \
@ -25,5 +25,14 @@ RUN mkdir -p /opt/ass/uploads/thumbnails/ && \
touch /opt/ass/auth.json && \ touch /opt/ass/auth.json && \
touch /opt/ass/data.json touch /opt/ass/data.json
# Copy directory files (config.json, source files etc.)
COPY . ./
# Update npm to at least npm 8, then install dependencies
RUN npm i -g npm@8 typescript && \
npm i --save-dev && \
npm run build && \
chown -R ass /usr/local/bin/npm
# Start ass # Start ass
CMD npm start CMD npm start

Loading…
Cancel
Save