Skip to content

Commit

Permalink
Update Docker configuration to use Nginx and adjust port mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
sentemon committed Jan 4, 2025
1 parent 04be65d commit a3ca867
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
context: ./frontend
dockerfile: Dockerfile
ports:
- "4200:4200"
- "4200:80"
depends_on:
post-service:
condition: service_healthy
Expand Down
37 changes: 19 additions & 18 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down

0 comments on commit a3ca867

Please sign in to comment.