diff --git a/.gitignore b/.gitignore index c92b8ee0e..ad3d168a2 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,6 @@ packages/files/uploads/* data/* !data/.gitkeep + +logs/* +!logs/.gitkeep diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..aacdbfa44 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM node:18.13.0-alpine + +RUN apk add --update \ + bash \ + curl \ + py3-pip \ + && rm -rf /var/cache/apk/* + +ENV NODE_ENV production + +RUN corepack enable + +RUN pip install --no-cache-dir --upgrade supervisor + +RUN mkdir -p /var/lib/server/logs + +COPY docker/supervisord.conf /etc/supervisord.conf + +COPY docker/docker-entrypoint.sh /usr/local/bin/ + +COPY . /opt/server + +WORKDIR /opt/server + +RUN yarn install --immutable + +RUN yarn build + +ENTRYPOINT ["docker-entrypoint.sh"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index ce71bf308..a6818c35d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,12 @@ -version: '3.8' services: + server: + build: . + env_file: .env + volumes: + - ./logs:/var/lib/server/logs + db: - image: mysql:5.6 + image: mysql:8 environment: MYSQL_DATABASE: '${DB_DATABASE}' MYSQL_USER: '${DB_USERNAME}' diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh new file mode 100755 index 000000000..20fddb740 --- /dev/null +++ b/docker/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Setup environment variables + +printenv | grep API_GATEWAY_ | sed 's/API_GATEWAY_//g' > /opt/server/packages/api-gateway/.env + +# Run supervisor + +supervisord -c /etc/supervisord.conf + +exec "$@" \ No newline at end of file diff --git a/docker/supervisord.conf b/docker/supervisord.conf new file mode 100644 index 000000000..6e833c809 --- /dev/null +++ b/docker/supervisord.conf @@ -0,0 +1,11 @@ +[supervisord] +nodaemon=true +logfile=/tmp/supervisord.log + +[program:api-gateway] +directory=/opt/server +command=yarn start:api-gateway +autostart=true +autorestart=true +stdout_logfile=/var/lib/server/logs/api-gateway.log +stderr_logfile=/var/lib/server/logs/api-gateway.err \ No newline at end of file diff --git a/logs/.gitkeep b/logs/.gitkeep new file mode 100644 index 000000000..e69de29bb