Finish project

This commit is contained in:
Rayan Konecny do Nascimento 2025-04-23 02:02:37 +00:00
parent 5037b459b2
commit b0a6104eb9
5 changed files with 39 additions and 19 deletions

View file

@ -1,17 +1,28 @@
# Dockerfile
# Etapa 1 - Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
# Gera a aplicação Angular + SSR
RUN npm run build
# Etapa 2 - Runtime
FROM node:20-alpine
WORKDIR /app
# Copiar arquivos e instalar dependências
COPY package*.json ./
RUN npm install -g @angular/cli && npm install
# Copia apenas os arquivos necessários para rodar SSR
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/node_modules /app/node_modules
COPY --from=builder /app/package*.json /app/
# Copiar o restante do código
COPY . .
# Expor a porta do servidor SSR
EXPOSE 4000
# Expor a porta padrão do Angular
EXPOSE 4200
# Comando para servir o Angular na rede
CMD ["ng", "serve", "--host", "0.0.0.0"]
# Rodar o server SSR compilado
CMD ["node", "dist/my-task-board-angular/server/server.mjs"]

View file

@ -9,7 +9,7 @@
"watch": "ng build --watch --configuration development",
"test": "ng test",
"test:watch": "ng test --watch",
"serve:ssr:my-task-board-angular": "node dist/my-task-board-angular/server/server.mjs"
"start:ssr": "node dist/my-task-board-angular/server/server.mjs"
},
"private": true,
"dependencies": {

View file

@ -1,16 +1,14 @@
version: "3.9"
services:
my-task-board:
angular-ssr:
build:
context: .
dockerfile: Dockerfile # Dockerfile para o Angular
container_name: my-task-board
dockerfile: Dockerfile
container_name: angular-ssr
ports:
- "4200:4200"
volumes:
- .:/app
command: ["npx", "ng", "serve", "--host", "0.0.0.0", "--poll=2000"]
- "4000:4000"
restart: unless-stopped
depends_on:
- json-server
json-server:

View file

@ -14,6 +14,8 @@ const browserDistFolder = resolve(serverDistFolder, '../browser');
const app = express();
const angularApp = new AngularNodeAppEngine();
/**
* Example Express Rest API endpoints can be defined here.
* Uncomment and define endpoints as necessary.

9
vite.config.ts Normal file
View file

@ -0,0 +1,9 @@
import { defineConfig } from 'vite';
export default defineConfig({
server: {
host: '0.0.0.0',
allowedHosts: ['all'],
},
});