Skip to content

Commit

Permalink
move DOCKER_USER/UID to entrypoint script
Browse files Browse the repository at this point in the history
  • Loading branch information
myrho committed Jan 19, 2024
1 parent 01910fd commit 5aa0022
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
16 changes: 5 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ LABEL org.opencontainers.image.description="GraphSense's Web GUI for interactive
LABEL org.opencontainers.image.source="https://github.com/graphsense/graphsense-dashboard"

ENV DOCKER_USER=dockeruser
# override to get
ENV DOCKER_UID=1000
ENV REST_URL=http://localhost:9000
ARG DOCKER_UID=1000

RUN addgroup -S $DOCKER_USER && adduser -S $DOCKER_USER -G $DOCKER_USER -u $DOCKER_UID
#RUN addgroup -S $DOCKER_USER && adduser -S $DOCKER_USER -G $DOCKER_USER -u $DOCKER_UID

ENV WORKDIR=/app

Expand All @@ -20,8 +19,6 @@ RUN mkdir $WORKDIR && \


WORKDIR $WORKDIR
COPY ./docker/docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh

COPY ./elm.json.base ./elm-tooling.json ./index.html ./package*.json ./vite.config.js $WORKDIR/

Expand All @@ -38,16 +35,13 @@ COPY ./lib $WORKDIR/lib
COPY ./docker/site.conf /etc/nginx/http.d/
COPY ./generate.js $WORKDIR/generate.js

RUN chown -R $DOCKER_USER $WORKDIR && \
mkdir -p /usr/share/nginx/html /run/nginx && \
chown -R $DOCKER_USER /usr/share/nginx/html && \
chown -R $DOCKER_USER /var/lib/nginx && \
chown -R $DOCKER_USER /var/log/nginx && \
RUN mkdir -p /usr/share/nginx/html /run/nginx && \
rm -f /etc/nginx/http.d/default.conf

USER $DOCKER_USER
RUN npm install

COPY ./docker/docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "pid /tmp/nginx.pid;daemon off;"]
EXPOSE 8000
16 changes: 9 additions & 7 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#!/bin/ash
set -e

for plugin in `find ./plugins -mindepth 1 -maxdepth 1 -type d`; do
cd $WORKDIR/$plugin
npm install
cd -
done
echo $DOCKER_UID
echo $DOCKER_USER
addgroup $DOCKER_USER
adduser $DOCKER_USER -G $DOCKER_USER -u $DOCKER_UID -D

npm run build && cp -r $WORKDIR/dist/* /usr/share/nginx/html/
chown -R $DOCKER_USER $WORKDIR
chown -R $DOCKER_USER /usr/share/nginx/html
chown -R $DOCKER_USER /var/lib/nginx
chown -R $DOCKER_USER /var/log/nginx

sed -i "s|http://localhost:9000|$REST_URL|g" /usr/share/nginx/html/assets/index.*.js
su $DOCKER_USER

exec "$@"

0 comments on commit 5aa0022

Please sign in to comment.