Finish project
This commit is contained in:
parent
5037b459b2
commit
b0a6104eb9
5 changed files with 39 additions and 19 deletions
33
Dockerfile
33
Dockerfile
|
|
@ -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
|
FROM node:20-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copiar arquivos e instalar dependências
|
# Copia apenas os arquivos necessários para rodar SSR
|
||||||
COPY package*.json ./
|
COPY --from=builder /app/dist /app/dist
|
||||||
RUN npm install -g @angular/cli && npm install
|
COPY --from=builder /app/node_modules /app/node_modules
|
||||||
|
COPY --from=builder /app/package*.json /app/
|
||||||
|
|
||||||
# Copiar o restante do código
|
# Expor a porta do servidor SSR
|
||||||
COPY . .
|
EXPOSE 4000
|
||||||
|
|
||||||
# Expor a porta padrão do Angular
|
# Rodar o server SSR compilado
|
||||||
EXPOSE 4200
|
CMD ["node", "dist/my-task-board-angular/server/server.mjs"]
|
||||||
|
|
||||||
# Comando para servir o Angular na rede
|
|
||||||
CMD ["ng", "serve", "--host", "0.0.0.0"]
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
"watch": "ng build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"test:watch": "ng test --watch",
|
"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,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
version: "3.9"
|
version: "3.9"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
my-task-board:
|
angular-ssr:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile # Dockerfile para o Angular
|
dockerfile: Dockerfile
|
||||||
container_name: my-task-board
|
container_name: angular-ssr
|
||||||
ports:
|
ports:
|
||||||
- "4200:4200"
|
- "4000:4000"
|
||||||
volumes:
|
restart: unless-stopped
|
||||||
- .:/app
|
|
||||||
command: ["npx", "ng", "serve", "--host", "0.0.0.0", "--poll=2000"]
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- json-server
|
- json-server
|
||||||
json-server:
|
json-server:
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ const browserDistFolder = resolve(serverDistFolder, '../browser');
|
||||||
const app = express();
|
const app = express();
|
||||||
const angularApp = new AngularNodeAppEngine();
|
const angularApp = new AngularNodeAppEngine();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Example Express Rest API endpoints can be defined here.
|
* Example Express Rest API endpoints can be defined here.
|
||||||
* Uncomment and define endpoints as necessary.
|
* Uncomment and define endpoints as necessary.
|
||||||
|
|
|
||||||
9
vite.config.ts
Normal file
9
vite.config.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
server: {
|
||||||
|
host: '0.0.0.0',
|
||||||
|
allowedHosts: ['all'],
|
||||||
|
},
|
||||||
|
});
|
||||||
Loading…
Add table
Reference in a new issue