diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..bdfbb5d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +Dockerfile +.gitignore +.env.sample +config.sample.hjson +.git/ +.DS_Store +.vscode/ \ No newline at end of file diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..7539f74 --- /dev/null +++ b/.env.sample @@ -0,0 +1,10 @@ +# Connection secret for postgres. You should change it to a random password +# Please use only the characters `A-Za-z0-9`, without special characters or spaces + +POSTGRES_PASSWORD=my_password + +# If you do not know what you are doing, then you should not edit the values below +################################################################################### +POSTGRES_DB=kekkai +DB_HOST=postgres +POSTGRES_USER=postgres \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2e75a1a..77bd62f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ config.hjson node_modules/ -.DS_Store \ No newline at end of file +.DS_Store +postgres-data/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b869d9d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:20-alpine + +WORKDIR / + +COPY /package*.json . + +RUN npm install + +COPY /node_modules /node_modules + +COPY . . + +CMD ["node", "main.js"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..6c4b6b0 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,29 @@ +services: + parser: + build: + context: . + dockerfile: Dockerfile + volumes: + - './config.hjson:/config.hjson:ro' + depends_on: + - postgres + + postgres: + image: postgres:latest + restart: unless-stopped + env_file: .env + ports: + - '5432:5432' + volumes: + - ./postgres-data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $POSTGRES_USER"] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + parser: + driver: local + postgres: + driver: local