diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..26f5c15 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.github diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..04c0cbc --- /dev/null +++ b/.github/workflows/docker.yaml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bca2b2b --- /dev/null +++ b/Dockerfile @@ -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"]