Skip to content

Commit

Permalink
added build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Rene-Roscher committed Nov 25, 2023
1 parent 4c21fa6 commit 82f3928
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/image-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Deploy

on:
push:
branches:
- '*'

env:
IMAGE_NAME: nuxt3-tailwind-boiler

jobs:
auth-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}

build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}

- name: Build and push Docker image
run: |
docker build . --file Dockerfile --tag $IMAGE_NAME
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
COMMIT=$(echo "${{ github.sha }}")
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$COMMIT
docker push $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$COMMIT
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Build
FROM node:lts-alpine AS build-stage

WORKDIR /app

COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile

COPY . .

RUN yarn build

# Production
FROM node:lts-alpine AS production-stage

WORKDIR /app

COPY --from=build-stage /app/.output ./.output

RUN yarn install --frozen-lockfile --production

EXPOSE 3000

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

0 comments on commit 82f3928

Please sign in to comment.