Skip to content

Commit

Permalink
Merge pull request #80 from AlexSciFier/new-entypoint-script
Browse files Browse the repository at this point in the history
Added new entrypoint script
  • Loading branch information
AlexSciFier authored Oct 14, 2023
2 parents ba39272 + efcd13d commit 4858114
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ RUN npm ci --omit=dev
FROM --platform=$TARGETPLATFORM node:lts-slim
USER node
WORKDIR /app
COPY ./docker-entrypoint.sh ./
COPY --chown=node ./server ./
COPY --chown=node --from=srv-build /app/server ./
COPY --chown=node --from=ui-build /app/client/build ./public

RUN mkdir ./data
RUN mkdir ./public/static/media/background

ARG NODE_ENV=production
ARG FASTIFY_PLUGIN_TIMEOUT=10000
ENV NODE_ENV=${NODE_ENV}
Expand All @@ -46,4 +44,11 @@ ENV FASTIFY_ADDRESS=0.0.0.0
ENV FASTIFY_LOG_LEVEL=error
ENV FASTIFY_PLUGIN_TIMEOUT=${FASTIFY_PLUGIN_TIMEOUT}

CMD ["node", "server.js"]
ENV UID=1000
ENV GID=1000
ENV UMASK=022

RUN sed -i 's/\r$//g' docker-entrypoint.sh && \
chmod +x docker-entrypoint.sh

CMD [ "./docker-entrypoint.sh" ]
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ services:
- ./background:/app/public/static/media/background
environment:
- FASTIFY_PLUGIN_TIMEOUT=10000 # Set to 0 if ERR_AVVIO_PLUGIN_TIMEOUT error occurs.
- UID=1000
- GID=1000
- UMASK=22
restart: unless-stopped
ports:
- "80:3333"
19 changes: 19 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

echo "Setting umask to ${UMASK}"
umask ${UMASK}
echo "Creating database and backgrounds directories"
mkdir -p ./data ./public/static/media/background

if [ `id -u` -eq 0 ] && [ `id -g` -eq 0 ]; then
if [ "${UID}" -eq 0 ]; then
echo "Warning: it is not recommended to run as root user, please check your setting of the UID environment variable"
fi
echo "Changing ownership to ${UID}:${GID}"
chown -R "${UID}":"${GID}" ./data ./public/static/media/background
echo "Running Neonlink as user ${UID}:${GID}"
su-exec "${UID}":"${GID}" node server.js
else
echo "User set by docker; running Neonlink as `id -u`:`id -g`"
node server.js
fi

0 comments on commit 4858114

Please sign in to comment.