From c1092e12c012938f4bf78302c46d4e0077fe12e2 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Thu, 3 Jun 2021 21:40:34 +0100 Subject: [PATCH] Attempt 1 --- Dockerfile | 32 ++++++++++++++++++-------------- entrypoint.sh | 15 +++++++++++++++ 2 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index e249559e..807d151b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,30 @@ - -# Build Stage +# build stage FROM node:lts-alpine as build-stage -LABEL Maintainer Alicia Sykes - -RUN apk update WORKDIR /app -COPY package.json ./ -COPY yarn.lock ./ -RUN yarn install +COPY package*.json ./ +RUN yarn install --frozen-lockfile COPY . . RUN yarn build -# Production Stage -ENV PORT 80 +# production stage +FROM alpine:3.11 -FROM nginx:1.15.7-alpine as production-stage +ENV USER darkhttpd +ENV GROUP darkhttpd +ENV GID 911 +ENV UID 911 +ENV PORT 8080 -COPY --from=build-stage /app/dist /usr/share/nginx/html +RUN addgroup -S ${GROUP} -g ${GID} && adduser -D -S -u ${UID} ${USER} ${GROUP} && \ + apk add -U --no-cache su-exec darkhttpd + +COPY --from=build-stage --chown=${USER}:${GROUP} /app/dist /www/ +COPY --from=build-stage --chown=${USER}:${GROUP} /app/dist/assets /www/default-assets +COPY entrypoint.sh /entrypoint.sh EXPOSE ${PORT} -VOLUME /usr/share/nginx/html/item-icons -CMD ["nginx", "-g", "daemon off;"] +VOLUME /www/assets +ENTRYPOINT ["/bin/sh", "/entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..45e2caa4 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Ensure default assets are present. +while true; do echo n; done | cp -Ri /www/default-assets/* /www/assets/ &> /dev/null + +# Ensure compatibility with previous version (config.yml was in the root directory) +if [ -f "/www/config.yml" ]; then + yes n | cp -i /www/config.yml /www/assets/ &> /dev/null +fi + +# Install default config if no one is available. +yes n | cp -i /www/default-assets/config.yml.dist /www/assets/config.yml &> /dev/null + +chown -R $UID:$GID /www/assets +exec su-exec $UID:$GID darkhttpd /www/ --no-listing --port "$PORT" \ No newline at end of file