Skip to content

Commit

Permalink
chore: add docker gha caching
Browse files Browse the repository at this point in the history
  • Loading branch information
pkarolyi committed Apr 28, 2024
1 parent 839902f commit a5cf7c4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.DS_Store
.git
.github
blobs
coverage
dist
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
- name: Build and push image to Dockerhub
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/arm64/v8
cache-from: type=gha
cache-to: type=gha,mode=max
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ jobs:
uses: actions/checkout@v4
- name: Set up buildx
uses: docker/setup-buildx-action@v3
- name: Expose GitHub Runtime for caching
uses: crazy-max/ghaction-github-runtime@v3
- name: Build docker images
run: docker compose build
- name: Test API with turborepo
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ RUN apk --no-cache add tini

WORKDIR /garden-snail

RUN chown -R node:node .
COPY --chown=node:node package.json pnpm-lock.yaml ./
COPY package.json pnpm-lock.yaml ./

# with NODE_ENV=production pnpm will not install devDependencies
ENV NODE_ENV=production
RUN pnpm install --frozen-lockfile

COPY --from=builder --chown=node:node /garden-snail/dist ./dist
COPY --from=builder /garden-snail/dist ./dist

USER node
EXPOSE 3000
ENTRYPOINT ["/sbin/tini", "node", "dist/main"]
11 changes: 10 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
services:
garden-snail:
build: .
build:
context: .
cache_from:
- type=gha
cache_to:
- type=gha,mode=max
ports:
- "3000:3000"
test:
build:
context: integration
cache_from:
- type=gha
cache_to:
- type=gha,mode=max
depends_on:
- garden-snail

0 comments on commit a5cf7c4

Please sign in to comment.