Skip to content

Commit

Permalink
Build Docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
roelofr committed Nov 23, 2023
1 parent 3884edc commit 086091c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.nuxt/
node_modules/
65 changes: 50 additions & 15 deletions .github/workflows/verify-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,70 @@ jobs:
- name: Run linter
run: npm run lint

- name: Build application
- name: Generate static application
run: npm run generate

- name: Upload application
uses: actions/upload-artifact@v3
with:
name: output
name: static
path: .output/public/
if-no-files-found: error

- name: Update application version
if: startsWith(github.ref, 'refs/tags/v')
run: |
# Load version from Git
npm version --allow-same-version --no-git-tag-version from-git
- name: Generate SSR application
run: npm run build

- name: Upload application
uses: actions/upload-artifact@v3
with:
name: ssr
path: .output/
if-no-files-found: error

# Set as env
export NODE_PKG_VERSION=$( jq -r '.version' package.json )
echo "NODE_PKG_VERSION=${NODE_PKG_VERSION}" >> $GITHUB_ENV
release:
name: Release application
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download static application
uses: actions/download-artifact@v3
with:
name: static
path: static

- name: Bundle application
if: startsWith(github.ref, 'refs/tags/v')
working-directory: .output/public
run: tar -czf ../../minisites.tgz ./*
working-directory: static
run: tar -czf ../minisites.tgz ./*

- name: Release
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
name: Version ${{ env.NODE_PKG_VERSION }}
files: minisites.tgz
generate_release_notes: true

- name: Download SSR application
uses: actions/download-artifact@v3
with:
name: ssr
path: .output

- name: Determine version tag
id: version
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Build Docker image
uses: docker/build-push-action@v2
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
with:
context: app
file: Dockerfile
push: true
tags: |
${{ github.repository }}:latest
${{ github.repository }}:${{ github.ref }}
${{ github.repository }}:${{ steps.version.outputs.tag }}
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:lts-alpine

# Copy app
COPY .output /opt/app

# Expose proper port
ENV NITRO_PORT=3000
ENV NITRO_HOST=0.0.0.0

EXPOSE 3000

# Update entrypoint
ENTRYPOINT [ "node", "/opt/app/server/index.mjs" ]

0 comments on commit 086091c

Please sign in to comment.