Skip to content

Commit a14dd27

Browse files
authored
Merge pull request #99 from teacoder-team/dev
chore(ci): refactor build-push
2 parents 27e267b + fe37e12 commit a14dd27

3 files changed

Lines changed: 44 additions & 109 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 0 additions & 107 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
id-token: write
13+
14+
jobs:
15+
build-and-push:
16+
name: Build and Push
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Log in to Docker Hub
28+
uses: docker/login-action@v3
29+
with:
30+
username: ${{ secrets.DOCKERHUB_USERNAME }}
31+
password: ${{ secrets.DOCKERHUB_TOKEN }}
32+
33+
- name: Build and push Docker image
34+
uses: docker/build-push-action@v6
35+
with:
36+
context: .
37+
file: ./Dockerfile
38+
push: true
39+
tags: |
40+
${{ secrets.DOCKERHUB_USERNAME }}/backend:latest
41+
${{ secrets.DOCKERHUB_USERNAME }}/backend:${{ github.sha }}
42+
cache-from: type=gha
43+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ ENV NODE_ENV=production
2222

2323
COPY --chown=nodejs:nodejs package.json yarn.lock ./
2424

25-
RUN yarn install --production
25+
RUN yarn install --immutable
2626

2727
COPY --chown=nodejs:nodejs --from=builder /app/dist ./dist
2828
COPY --chown=nodejs:nodejs --from=builder /app/prisma/generated ./prisma/generated
2929

3030
CMD ["node", "dist/main"]
31-

0 commit comments

Comments
 (0)