summary refs log tree commit diff
diff options
context:
space:
mode:
authorNobody <17956512+n0bodysec@users.noreply.github.com>2022-07-20 03:43:34 -0300
committerGitHub <noreply@github.com>2022-07-20 09:43:34 +0300
commitdb2b94c0a3a0063e1b32e524d4a0cde562f2686b (patch)
treed344adad5e35ec7176e18fb2dafd53a46732b868
parentchore: fix package.json scripts (diff)
downloadserver-db2b94c0a3a0063e1b32e524d4a0cde562f2686b.tar.xz
chore!: update docker scripts (#797)
BREAKING CHANGE: this new docker image no longer clones this repository. Some manual steps are required
* chore!: update docker scripts
* chore: fix paths in docker scripts
* chore: add config docker compose
-rw-r--r--.docker/env1
-rw-r--r--.dockerignore2
-rw-r--r--Dockerfile32
-rw-r--r--docker-compose.cfg.yml6
-rw-r--r--docker-compose.yml28
5 files changed, 16 insertions, 53 deletions
diff --git a/.docker/env b/.docker/env
deleted file mode 100644
index 595b7ba2..00000000
--- a/.docker/env
+++ /dev/null
@@ -1 +0,0 @@
-MONGO_URL=mongodb://db:27017/fosscord?readPreference=secondaryPreferred
diff --git a/.dockerignore b/.dockerignore
deleted file mode 100644
index 7ee311a4..00000000
--- a/.dockerignore
+++ /dev/null
@@ -1,2 +0,0 @@
-node_modules/
-db/
diff --git a/Dockerfile b/Dockerfile
index 3c8a0b31..64130e51 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,8 +1,6 @@
 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
@@ -13,28 +11,12 @@ ENV ADMIN_PORT=3005
 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
+RUN apk add --no-cache --update git python3 py-pip make build-base
+RUN ln -s /usr/bin/python3 /usr/bin/python
 
-# optionl: packages for debugging/development
-RUN apk add --no-cache sqlite
+# Run as non-root user
+# RUN adduser -D fosscord
+# USER fosscord
 
-# 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
-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"]
+WORKDIR /srv/fosscord-server/bundle
+ENTRYPOINT ["npm", "run", "start:bundle"]
\ No newline at end of file
diff --git a/docker-compose.cfg.yml b/docker-compose.cfg.yml
new file mode 100644
index 00000000..18a7031d
--- /dev/null
+++ b/docker-compose.cfg.yml
@@ -0,0 +1,6 @@
+version: '3.9'
+
+services:
+
+  fosscord:
+    entrypoint: [ "npm", "run", "setup" ]
diff --git a/docker-compose.yml b/docker-compose.yml
index 13696f6f..4dc1ee41 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,46 +1,24 @@
-version: '3.8'
+version: '3.9'
 
 services:
+
   fosscord:
     container_name: fosscord
     image: fosscord
     restart: on-failure:5
-    # depends_on: mariadb
     build: .
     ports:
       - '3001-3005:3001-3005'
     volumes:
-      # - ./data/:${WORK_DIR:-/srv/fosscord-server}/data/
-      - data:${WORK_DIR:-/srv/fosscord-server}/
+      - ./:/srv/fosscord-server/
     environment:
-      WORK_DIR: ${WORK_DIR:-/srv/fosscord-server}
-      DEV_MODE: ${DEV_MODE:-0}
       THREADS: ${THREADS:-1}
-      DATABASE: ${DATABASE:-../../data/database.db}
-      STORAGE_LOCATION: ${STORAGE_LOCATION:-../../data/files/}
       HTTP_PORT: 3001
       WS_PORT: 3002
       CDN_PORT: 3003
       RTC_PORT: 3004
       ADMIN_PORT: 3005
 
-  # mariadb:
-  #   image: mariadb:latest
-  #   restart: on-failure:5
-  #   environment:
-  #     MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-secr3tpassw0rd}
-  #     MYSQL_DATABASE: ${MYSQL_DATABASE:-fosscord}
-  #     MYSQL_USER: ${MYSQL_USER:-fosscord}
-  #     MYSQL_PASSWORD: ${MYSQL_PASSWORD:-password1}
-  #   networks:
-  #     - default
-  #   volumes:
-  #     - mariadb:/var/lib/mysql
-
-volumes:
-  data:
-  # mariadb:
-
 networks:
   default:
     name: fosscord