Skip to content

Commit

Permalink
feat: move build stage to Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
IKatsuba committed Apr 6, 2024
1 parent 7a13b39 commit e0c6389
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
node-version: 20
- run: |
npm ci
npx nx build api -c=production
- name: Docker Compose
run: |
docker-compose -f compose.test.yml up -d
Expand Down
25 changes: 2 additions & 23 deletions .github/workflows/publish-to-docker-hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,10 @@ jobs:
echo "::set-output name=secrets_available::false"
fi
shell: bash
build:
needs: check_secrets
if: ${{ needs.check_secrets.outputs.secrets_available == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: npm install and build
run: |
npm ci
npx nx build api -c=production
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: build
path: dist
if-no-files-found: error
publish:
runs-on: ubuntu-latest
needs: build
needs: check_secrets
if: ${{ needs.check_secrets.outputs.secrets_available == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -69,11 +53,6 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Download production artifacts
uses: actions/download-artifact@v3
with:
name: build
path: dist
- name: Build and push
uses: docker/build-push-action@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion apps/api-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
}
},
"tags": [],
"implicitDependencies": []
"implicitDependencies": ["api"]
}
10 changes: 6 additions & 4 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM node:18-alpine

FROM node:20 as build
WORKDIR /app

COPY . .
RUN npm ci && npx nx build api -c=production

FROM node:20-alpine
WORKDIR /app
COPY . .
COPY --from=build /app/dist/apps/api ./dist/apps/api
RUN npm ci --omit=dev

EXPOSE ${PORT:-3000}

CMD ["npm", "run", "start:prod", "--silent"]

0 comments on commit e0c6389

Please sign in to comment.