Skip to content

Commit

Permalink
dockerfile and build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-aschlackman committed Feb 16, 2024
1 parent 5042a72 commit 2de3189
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Prepare
id: prep
Expand Down Expand Up @@ -50,17 +50,17 @@ jobs:
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
Expand Down
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
FROM node:16-alpine as builder
FROM node:20-alpine as builder

COPY package.json package-lock.json ./

# Storing node modules on a separate layer will prevent unnecessary npm install at each build
RUN npm set progress=false && \
npm config set depth 0 && \
npm cache clean --force && \
npm config set unsafe-perm true
npm cache clean --force

RUN npm ci && mkdir -p /ng-app/dist && cp -R ./node_modules ./ng-app

WORKDIR /ng-app

COPY . .

RUN $(npm bin)/ng build --resources-output-path=assets/fonts --configuration production
RUN npx ng build

### Stage 2: Setup ###

Expand All @@ -25,7 +24,7 @@ RUN rm -rf /usr/share/nginx/html/*
COPY default.conf /etc/nginx/conf.d/default.conf
COPY scripts/nginx-basehref.sh /docker-entrypoint.d/90-basehref.sh
COPY scripts/settings-from-env.sh /docker-entrypoint.d/91-settings-from-env.sh
COPY --from=builder /ng-app/dist /usr/share/nginx/html
COPY --from=builder /ng-app/dist/browser /usr/share/nginx/html
RUN chown -R nginx:nginx /usr/share/nginx/html && chmod +x /docker-entrypoint.d/90-basehref.sh && chmod +x /docker-entrypoint.d/91-settings-from-env.sh
USER nginx

Expand Down
3 changes: 1 addition & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"options": {
"preserveSymlinks": true,
"outputPath": {
"base": "dist",
"browser": ""
"base": "dist"
},
"index": "src/index.html",
"tsConfig": "src/tsconfig.app.json",
Expand Down

0 comments on commit 2de3189

Please sign in to comment.