From 55de4319edcbbdf7e7fd613b9f3915293679dc78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Fri, 3 Feb 2023 11:26:06 +0100 Subject: [PATCH] feat: add initial supervisor setup --- .gitignore | 3 +++ Dockerfile | 29 +++++++++++++++++++++++++++++ docker-compose.yml | 9 +++++++-- docker/docker-entrypoint.sh | 11 +++++++++++ docker/supervisord.conf | 11 +++++++++++ logs/.gitkeep | 0 6 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100755 docker/docker-entrypoint.sh create mode 100644 docker/supervisord.conf create mode 100644 logs/.gitkeep 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