Skip to content

Commit ce9ba09

Browse files
committed
build: adding dockerfile for our backend and frontend with dockercompose in root to up both services and database
1 parent ce86fd1 commit ce9ba09

8 files changed

Lines changed: 157 additions & 13 deletions

File tree

backend/.dockerignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Node modules e caches
2+
node_modules
3+
npm-debug.log
4+
yarn-error.log
5+
6+
# Builds locais
7+
dist
8+
.out
9+
.next
10+
coverage
11+
build
12+
13+
# Testes e configuração de testes
14+
__tests__/
15+
test/
16+
*.spec.ts
17+
*.test.ts
18+
jest.config.js
19+
vitest.config.ts
20+
21+
# Arquivos de ambiente e configs locais
22+
.env
23+
.env.local
24+
.env.development
25+
.env.test
26+
27+
./prisma/seed.ts
28+
29+
# Editor / sistema
30+
.vscode
31+
.idea
32+
.DS_Store
33+
*.swp
34+
*.log
35+
36+
# Dockerfile local alternativo
37+
Dockerfile.dev
38+
docker-compose.yml

backend/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM node:22.20.0-alpine AS build
2+
WORKDIR /build
3+
COPY prisma/ ./prisma
4+
COPY package*.json ./
5+
RUN npm install
6+
COPY . .
7+
RUN npm run build
8+
9+
FROM node:22.10.0-alpine AS production
10+
WORKDIR /app
11+
COPY --from=build /build/node_modules ./node_modules
12+
COPY --from=build /build/package*.json ./
13+
COPY --from=build /build/dist ./dist
14+
COPY --from=build /build/tsconfig.json ./
15+
COPY --from=build /build/prisma ./prisma
16+
EXPOSE 3000
17+
CMD ["sh", "-c", "npx prisma migrate deploy && npx prisma generate && npm run start:dev"]

backend/docker-compose.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

backend/tsconfig.build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "./tsconfig.json",
3-
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
3+
"exclude": ["node_modules", "test", "dist", "**/*spec.ts", "prisma/seed.ts"]
44
}

docker-compose.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
version: "3.9"
2+
services:
3+
postgres:
4+
image: postgres:17.4
5+
restart: always
6+
env_file:
7+
- ./backend/.env
8+
environment:
9+
POSTGRES_HOST_AUTH_METHOD: trust
10+
POSTGRES_DB: ${DATABASE_NAME}
11+
ports:
12+
- 5432:5432
13+
volumes:
14+
- pgdata:/var/lib/postgresql/data
15+
networks:
16+
- app-network
17+
18+
backend:
19+
build:
20+
context: ./backend
21+
dockerfile: Dockerfile
22+
container_name: nest-backend
23+
ports:
24+
- 3000:3000
25+
env_file:
26+
- ./backend/.env
27+
depends_on:
28+
- postgres
29+
healthcheck:
30+
test: ["CMD", "wget", "-qO-", "http://localhost:3000/health"]
31+
interval: 10s
32+
timeout: 5s
33+
retries: 3
34+
networks:
35+
- app-network
36+
37+
frontend:
38+
build:
39+
context: ./frontend
40+
dockerfile: Dockerfile
41+
container_name: vue-frontend
42+
ports:
43+
- 8080:80
44+
depends_on:
45+
- backend
46+
networks:
47+
- app-network
48+
49+
volumes:
50+
pgdata:
51+
52+
networks:
53+
app-network:
54+
driver: bridge

frontend/.dockerignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Node modules e caches
2+
node_modules
3+
npm-debug.log
4+
yarn-error.log
5+
6+
# Builds locais
7+
dist
8+
.out
9+
.next
10+
coverage
11+
build
12+
13+
# Testes e configuração de testes
14+
__tests__/
15+
test/
16+
*.spec.ts
17+
*.test.ts
18+
jest.config.js
19+
vitest.config.ts
20+
21+
# Arquivos de ambiente e configs locais
22+
.env
23+
.env.local
24+
.env.development
25+
.env.test
26+
27+
# Editor / sistema
28+
.vscode
29+
.idea
30+
.DS_Store
31+
*.swp
32+
*.log
33+
34+
# Dockerfile local alternativo
35+
Dockerfile.dev
36+
docker-compose.yml

frontend/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM node:22.20.0-alpine AS build
2+
WORKDIR /app
3+
COPY package*.json ./
4+
RUN npm install
5+
COPY . .
6+
RUN npm run build
7+
8+
FROM nginx:1.27-alpine
9+
COPY --from=build /app/dist /usr/share/nginx/html
10+
EXPOSE 80

frontend/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
},
99
"scripts": {
1010
"dev": "vite",
11-
"build": "run-p type-check \"build-only {@}\" --",
11+
"build": "vite build",
1212
"preview": "vite preview",
13-
"build-only": "vite build",
14-
"type-check": "vue-tsc --build",
1513
"lint": "eslint . --fix",
1614
"format": "prettier --write src/"
1715
},

0 commit comments

Comments
 (0)