eletrotupi / tcc/ commit / fbc5dfe

api: fix api specs using wrong db inside container

Pedro Lucas Porcellis porcellis@eletrotupi.com · 6 months ago fbc5dfefcd8133f6f556648d98b587898a03578d Browse files
Parents a1fd052
Changed files
6
Additions
+13
Deletions
-4
/dev/null → api/.env.development
1 +
DATABASE_URL="postgres://user:password@orbit_db:5432/orbit_dev"
2 +
JWT_SECRET="sky-is-crying"
3 +
FRONTEND_URL=http://192.168.3.96:8000
api/.env.test modified+1
api/.env.test
1 1
DATABASE_URL="postgres://user:password@orbit_db:5432/orbit_test"
2 +
NODE_ENV=test
2 3
JWT_SECRET="test-secret-key"
3 4
FRONTEND_URL=http://localhost:8081
api/.gitignore modified+1
api/.gitignore
1 1
node_modules
2 2
.env
3 +
.env.development
3 4
src/generated/prisma
4 5
orbit.db
api/Dockerfile modified+4
api/Dockerfile
1 1
FROM node:24-alpine3.23
2 2

3 3
RUN apk add -U bash postgresql17-client build-base yaml-dev
4 4

5 5
ARG UID=1000
11 11

12 12
COPY --chown="${UID}:${GID}" package*.json .
13 13

14 14
RUN npm i --frozen-lockfile
15 15

16 +
COPY --chown="${UID}:${GID}" prisma ./prisma/
17 +

18 +
RUN npx prisma generate
19 +

16 20
COPY --chown="${UID}:${GID}" . .
17 21

18 22
EXPOSE 3000
19 23

20 24
CMD ["npm", "run", "dev"]
api/package.json modified+3 -3
api/package.json
1 1
{
2 2
  "name": "orbit-api",
3 3
  "version": "0.0.0",
4 4
  "description": "",
5 5
  "license": "ISC",
9 9
    "test": "tests"
10 10
  },
11 11
  "scripts": {
12 12
    "build": "tsc && tsc-alias",
13 13
    "start": "ts-node -r tsconfig-paths/register src/index.ts",
14 -
    "test": "npm run test:setup && NODE_ENV=test npx ava",
14 +
    "test": "npm run test:setup && dotenv -e .env.test -o -- npx ava",
15 15
    "test:setup": "npm run test:setup:generate && npm run test:setup:migrate",
16 -
    "test:setup:generate": "dotenv -e .env.test npx prisma generate",
17 -
    "test:setup:migrate": "dotenv -e .env.test npx prisma db push",
16 +
    "test:setup:generate": "dotenv -e .env.test -o -- npx prisma generate",
17 +
    "test:setup:migrate": "dotenv -e .env.test -o -- npx prisma db push",
18 18
    "test:watch": "npm run test:setup && NODE_ENV=test npx ava --watch",
19 19
    "dev": "prisma generate && prisma migrate deploy && npm run start"
20 20
  },
21 21
  "dependencies": {
22 22
    "@prisma/adapter-better-sqlite3": "^7.5.0",
49 49
    "tsconfig-paths": "^4.2.0",
50 50
    "tsx": "^4.21.0",
51 51
    "typescript": "^6.0.2"
52 52
  }
53 53
}
docker-compose.yml modified+1 -1
docker-compose.yml
1 1
services:
2 2
  orbit_db:
3 3
    image: postgres:17-alpine
4 4
    shm_size: 1g
5 5
    user: postgres
24 24
      - ./api:/app
25 25
      - /app/node_modules
26 26
    ports:
27 27
      - 3000:3000
28 28
    env_file:
29 -
      - api/.env
29 +
      - api/.env.development
30 30
    depends_on:
31 31
      orbit_db:
32 32
        condition: service_healthy
33 33
    restart: always
34 34

35 35
volumes:
36 36
  db_data: