From e6d14f48bd27f0ca6d44cc232083235b6d88fc78 Mon Sep 17 00:00:00 2001 From: leca Date: Wed, 30 Apr 2025 18:31:21 +0300 Subject: [PATCH] migration in deployment --- Dockerfile | 3 +-- docker-compose.yml | 3 ++- entrypoint.sh | 4 ++++ patch | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 entrypoint.sh create mode 100644 patch diff --git a/Dockerfile b/Dockerfile index 963556b..5938c34 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,5 @@ ARG APP_PORT ENV APP_PORT $APP_PORT COPY . . RUN npm i - EXPOSE $APP_PORT -ENTRYPOINT ["node", "./src/index.js"] \ No newline at end of file +ENTRYPOINT ["bash", "./entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index 7a90a6a..66af735 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,6 +10,7 @@ services: volumes: - ./data/uploads:${DATA_DIR} database: + hostname: database image: 'postgres:15' volumes: - ./data/db:/var/lib/postgresql/data @@ -21,4 +22,4 @@ services: POSTGRES_PASSWORD: ${DBPASS} POSTGRES_DB: ${DBNAME} healthcheck: - test: ["CMD", "pg_isready", "-U", "${DBUSER}"] \ No newline at end of file + test: ["CMD", "pg_isready", "-U", "${DBUSER}"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..894f8b9 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +npm run migrate up +node src/index.js diff --git a/patch b/patch new file mode 100644 index 0000000..ee3128d --- /dev/null +++ b/patch @@ -0,0 +1,32 @@ +diff --git a/Dockerfile b/Dockerfile +index 963556b..5938c34 100644 +--- a/Dockerfile ++++ b/Dockerfile +@@ -3,6 +3,5 @@ ARG APP_PORT + ENV APP_PORT $APP_PORT + COPY . . + RUN npm i +- + EXPOSE $APP_PORT +-ENTRYPOINT ["node", "./src/index.js"] +\ No newline at end of file ++ENTRYPOINT ["bash", "./entrypoint.sh"] +diff --git a/docker-compose.yml b/docker-compose.yml +index 7a90a6a..66af735 100644 +--- a/docker-compose.yml ++++ b/docker-compose.yml +@@ -10,6 +10,7 @@ services: + volumes: + - ./data/uploads:${DATA_DIR} + database: ++ hostname: database + image: 'postgres:15' + volumes: + - ./data/db:/var/lib/postgresql/data +@@ -21,4 +22,4 @@ services: + POSTGRES_PASSWORD: ${DBPASS} + POSTGRES_DB: ${DBNAME} + healthcheck: +- test: ["CMD", "pg_isready", "-U", "${DBUSER}"] +\ No newline at end of file ++ test: ["CMD", "pg_isready", "-U", "${DBUSER}"]