chore(devops): adicionar suporte a docker
- adiciona dockerfiles e docker-compose para backend, frontend e postgres - atualiza README com instruções e libera CORS para porta 4173master
parent
f9b62dcc4e
commit
ed247c423e
13
README.md
13
README.md
|
|
@ -31,6 +31,19 @@ Plataforma interna para catalogar servidores corporativos e facilitar consultas
|
||||||
3. **Testar via Postman**
|
3. **Testar via Postman**
|
||||||
Importe `postman_collection.json`. Rode "Auth / Login" para setar cookies e seguir para os demais endpoints.
|
Importe `postman_collection.json`. Rode "Auth / Login" para setar cookies e seguir para os demais endpoints.
|
||||||
|
|
||||||
|
## Executar com Docker
|
||||||
|
1. Crie um `.env` na pasta `frontend/` se precisar sobrescrever variáveis (opcional).
|
||||||
|
2. Construa e suba tudo (Postgres + backend + frontend):
|
||||||
|
```bash
|
||||||
|
docker compose up --build
|
||||||
|
```
|
||||||
|
3. Endpoints expostos:
|
||||||
|
- API: `http://localhost:8080`
|
||||||
|
- Swagger UI: `http://localhost:8080/swagger-ui.html`
|
||||||
|
- Frontend: `http://localhost:4173`
|
||||||
|
|
||||||
|
Variáveis sensíveis (ex.: `JWT_SECRET`, credenciais do banco) podem ser ajustadas diretamente no `docker-compose.yml` ou via arquivos `.env`.
|
||||||
|
|
||||||
## Documentação específica
|
## Documentação específica
|
||||||
- Backend: `backend/README.md`
|
- Backend: `backend/README.md`
|
||||||
- Frontend: `frontned/README.md`
|
- Frontend: `frontned/README.md`
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
build
|
||||||
|
.gradle
|
||||||
|
.idea
|
||||||
|
*.iml
|
||||||
|
*.log
|
||||||
|
HELP.md
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
FROM gradle:8.10.2-jdk21 AS builder
|
||||||
|
WORKDIR /workspace
|
||||||
|
|
||||||
|
COPY gradlew .
|
||||||
|
COPY gradle gradle
|
||||||
|
COPY build.gradle settings.gradle ./
|
||||||
|
COPY src src
|
||||||
|
|
||||||
|
RUN chmod +x gradlew && ./gradlew bootJar --no-daemon
|
||||||
|
|
||||||
|
FROM eclipse-temurin:21-jre-alpine
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV JAVA_OPTS=""
|
||||||
|
|
||||||
|
COPY --from=builder /workspace/build/libs/*.jar app.jar
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app/app.jar"]
|
||||||
|
|
@ -80,7 +80,9 @@ public class SecurityConfig {
|
||||||
CorsConfiguration configuration = new CorsConfiguration();
|
CorsConfiguration configuration = new CorsConfiguration();
|
||||||
configuration.setAllowedOrigins(List.of(
|
configuration.setAllowedOrigins(List.of(
|
||||||
"http://localhost:5173",
|
"http://localhost:5173",
|
||||||
"http://127.0.0.1:5173"
|
"http://127.0.0.1:5173",
|
||||||
|
"http://localhost:4173",
|
||||||
|
"http://127.0.0.1:4173"
|
||||||
));
|
));
|
||||||
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS"));
|
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS"));
|
||||||
configuration.setAllowedHeaders(List.of("*"));
|
configuration.setAllowedHeaders(List.of("*"));
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres:15-alpine
|
||||||
|
container_name: servers-db
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: servermanager
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
ports:
|
||||||
|
- "5433:5432"
|
||||||
|
volumes:
|
||||||
|
- db-data:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: servers-backend
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
environment:
|
||||||
|
DB_HOST: db
|
||||||
|
DB_PORT: 5432
|
||||||
|
DB_NAME: servermanager
|
||||||
|
DB_SCHEMA: server-manager
|
||||||
|
DB_USER: postgres
|
||||||
|
DB_PASSWD: postgres
|
||||||
|
JWT_SECRET: change-me-change-me-change-me-change-me-change-me
|
||||||
|
ports:
|
||||||
|
- "8081:8080"
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: ./frontend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
VITE_BACKEND_URL: http://localhost:8081
|
||||||
|
container_name: servers-frontend
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
environment:
|
||||||
|
PORT: 4173
|
||||||
|
ports:
|
||||||
|
- "4173:4173"
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db-data:
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.turbo
|
||||||
|
.vite
|
||||||
|
.idea
|
||||||
|
*.log
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json yarn.lock ./
|
||||||
|
RUN corepack enable && yarn install --frozen-lockfile
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
ARG VITE_BACKEND_URL=http://localhost:8080
|
||||||
|
ENV VITE_BACKEND_URL=$VITE_BACKEND_URL
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
FROM node:20-alpine
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN npm install -g serve
|
||||||
|
ENV PORT=4173
|
||||||
|
|
||||||
|
COPY --from=builder /app/dist ./dist
|
||||||
|
|
||||||
|
EXPOSE 4173
|
||||||
|
|
||||||
|
CMD ["sh", "-c", "serve -s dist -l ${PORT}"]
|
||||||
Loading…
Reference in New Issue