Skip to content

Commit

Permalink
ci: add docker build on tag
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-bouvy committed May 3, 2024
1 parent 358c00b commit 4a35a87
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.github
39 changes: 39 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Push Docker Image to Docker Hub

on:
push:
tags:
- '*'

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
clickandmortar/mage-wizard:${{ github.ref_name }}
clickandmortar/mage-wizard:${{ github.sha }}
clickandmortar/mage-wizard:latest
platforms: linux/amd64,linux/arm64

- name: Clean up Buildx
uses: docker/build-push-action@v2
with:
cleanup: true
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:18 as builder

WORKDIR /app

COPY . /app

RUN npm install && npm run build


FROM node:18-alpine

WORKDIR /app

COPY --from=builder /app/dist /app

ENV NODE_ENV=production
ENV HOST=0.0.0.0

EXPOSE 3000

CMD ["node", "server/index.mjs"]

0 comments on commit 4a35a87

Please sign in to comment.