diff --git a/docker-compose.yml b/docker-compose.yml index e15dc2b..587e0f6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: context: ./frontend dockerfile: Dockerfile ports: - - "4200:4200" + - "4200:80" depends_on: post-service: condition: service_healthy diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 8cad09d..5fa2ab9 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,25 +1,26 @@ FROM node:20.17.0 AS build WORKDIR /app -RUN npm install -g @angular/cli@18.2.12 - COPY package*.json ./ RUN npm install COPY . . - -RUN npm run build -- --configuration production - -FROM node:20.17.0 -WORKDIR /app - -RUN npm install -g @angular/cli@18.2.12 - -COPY --from=build /app/dist /app/dist -COPY package*.json ./ - -RUN npm install --production - -EXPOSE 4200 -# Todo: change the way to run -CMD npx http-server ./dist/frontend --port 4200 --host 0.0.0.0 +RUN npm run build --prod + +FROM nginx:1.21.3-alpine +COPY --from=build /app/dist/frontend /usr/share/nginx/html + +RUN echo 'server {\ + listen 80;\ + listen [::]:80;\ + server_name localhost;\ + location / {\ + root /usr/share/nginx/html/browser;\ + try_files $uri $uri/ /index.html;\ + index index.html index.htm;\ + }\ + error_page 500 502 503 504 /50x.html;\ + location = /50x.html {\ + root /usr/share/nginx/html/browser;\ + }\ +}' > /etc/nginx/conf.d/default.conf diff --git a/frontend/angular.json b/frontend/angular.json index 5396bba..08b666f 100644 --- a/frontend/angular.json +++ b/frontend/angular.json @@ -15,11 +15,11 @@ "prefix": "app", "architect": { "build": { - "builder": "@angular-devkit/build-angular:browser", + "builder": "@angular-devkit/build-angular:application", "options": { "outputPath": "dist/frontend", "index": "src/index.html", - "main": "src/main.ts", + "browser": "src/main.ts", "polyfills": [ "zone.js" ],