Dockerfile
FROM node:18.20-alpine3.19 As build
WORKDIR /usr/local/app
COPY package*.json ./
RUN npm install
COPY ./ /usr/local/app/
ARG ENVIRONMENT=production
# Extract commit ID
ARG COMMIT_ID
RUN echo "Commit ID: $COMMIT_ID" > commit.txt
RUN echo 'Environment:' ${ENVIRONMENT}
RUN npm run build -- --configuration=${ENVIRONMENT}
### STAGE 2: Run ###
FROM nginx:1.25.3-alpine
COPY --from=build /usr/local/app/dist/my-app-client /usr/share/nginx/html
COPY --from=build /usr/local/app/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /usr/local/app/commit.txt /usr/share/nginx/html
EXPOSE 80
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
Whenever I run the container and visit the host I get:
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
Notes:
- Upgraded from Angular 16 -> 18
- Build is using @angular-devkit/build-angular:application, before was “@angular-devkit/build-angular:browser”. Not sure if I can use the old one but
- outputPath is dist/my-app-client in Angular.json
1