diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index 41d1bab..3983002 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -23,4 +23,4 @@ jobs: git pull docker system prune -f docker compose down - docker compose -f compose.yaml -f compose.prod.yaml up --build -d + docker compose -f compose.prod.yaml up --build -d diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index 322caec..0c11594 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -23,4 +23,4 @@ jobs: git pull docker system prune -f docker compose down - docker compose -f compose.yaml -f compose.prod.yaml up --build -d + docker compose -f compose.prod.yaml up --build -d diff --git a/Dockerfile b/Dockerfile index c311342..7166308 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,8 +13,8 @@ RUN apt-get update && apt-get install gnupg wget -y && \ rm -rf /var/lib/apt/lists/* WORKDIR /app -RUN chown -R node /app -USER node +RUN mkdir /db +RUN chown -R node:node /db COPY package.json package.json COPY package-lock.json package-lock.json @@ -22,4 +22,6 @@ RUN npm ci --include=dev COPY . . +USER node + CMD npm run dev \ No newline at end of file diff --git a/compose.prod.yaml b/compose.prod.yaml index fcfee80..5617e4e 100644 --- a/compose.prod.yaml +++ b/compose.prod.yaml @@ -1,5 +1,10 @@ services: app: + build: + context: . command: npm run start + restart: unless-stopped environment: - - NODE_ENV=production \ No newline at end of file + - NODE_ENV=production + volumes: + - ./db:/app/db diff --git a/compose.yaml b/compose.yaml index 6381629..b7b80b2 100644 --- a/compose.yaml +++ b/compose.yaml @@ -5,5 +5,4 @@ services: command: npm run dev restart: unless-stopped volumes: - - .:/app - - /app/node_modules # Avoid overwriting node_modules of main bind (.:/app) \ No newline at end of file + - .:/app \ No newline at end of file diff --git a/db/a b/db/a new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/initDb.js b/src/utils/initDb.js index 3125cf2..8991ee3 100644 --- a/src/utils/initDb.js +++ b/src/utils/initDb.js @@ -1,6 +1,6 @@ const sqlite3 = require('sqlite3').verbose(); -const db = new sqlite3.Database('db.sqlite', (err) => { +const db = new sqlite3.Database('db/db.sqlite', (err) => { if (err) { console.error("Error opening database:", err.message); return;