diff options
author | Nobody <17956512+n0bodysec@users.noreply.github.com> | 2022-03-08 12:10:06 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-08 18:10:06 +0300 |
commit | adce0c82d12c4a7f39be1a63dce4e15b913d07db (patch) | |
tree | 3b031433d761d50cc8afcf27d2f3e9dd9c167350 /Dockerfile | |
parent | fix(util): working invisible status type (diff) | |
download | server-adce0c82d12c4a7f39be1a63dce4e15b913d07db.tar.xz |
refactor(Docker): add working docker scripts (#671)
Diffstat (limited to 'Dockerfile')
-rw-r--r-- | Dockerfile | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/Dockerfile b/Dockerfile index d4b423ee..3c8a0b31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,40 @@ -FROM node:14 -WORKDIR /usr/src/fosscord-server/ -COPY . . -WORKDIR /usr/src/fosscord-server/bundle +FROM node:alpine + +# env vars +ENV WORK_DIR="/srv/fosscord-server" +ENV DEV_MODE=0 +ENV HTTP_PORT=3001 +ENV WS_PORT=3002 +ENV CDN_PORT=3003 +ENV RTC_PORT=3004 +ENV ADMIN_PORT=3005 + +# exposed ports (only for reference, see https://docs.docker.com/engine/reference/builder/#expose) +EXPOSE ${HTTP_PORT}/tcp ${WS_PORT}/tcp ${CDN_PORT}/tcp ${RTC_PORT}/tcp ${ADMIN_PORT}/tcp + +# install required apps +RUN apk add --no-cache --update git python2 py-pip make build-base + +# optionl: packages for debugging/development +RUN apk add --no-cache sqlite + +# download fosscord-server +WORKDIR $WORK_DIR/src +RUN git clone https://github.com/fosscord/fosscord-server.git . + +# setup and run +WORKDIR $WORK_DIR/src/bundle RUN npm run setup -EXPOSE 3001 -CMD [ "npm", "run", "start:bundle" ] +RUN npm install @yukikaze-bot/erlpack +# RUN npm install mysql --save + +# create update script +RUN printf '#!/bin/sh\n\ngit -C $WORK_DIR/src/ checkout master\ngit -C $WORK_DIR/src/ reset --hard HEAD\ngit -C $WORK_DIR/src/ pull\ncd $WORK_DIR/src/bundle/\nnpm run setup\n' > $WORK_DIR/update.sh +RUN chmod +x $WORK_DIR/update.sh + +# configure entrypoint file +RUN printf '#!/bin/sh\n\nDEV_MODE=${DEV_MODE:-0}\n\nif [ "$DEV_MODE" -eq 1 ]; then\n tail -f /dev/null\nelse\n cd $WORK_DIR/src/bundle/\n npm run start:bundle\nfi\n' > $WORK_DIR/entrypoint.sh +RUN chmod +x $WORK_DIR/entrypoint.sh + +WORKDIR $WORK_DIR +ENTRYPOINT ["./entrypoint.sh"] |