Skip to content

Commit

Permalink
ambitious try
Browse files Browse the repository at this point in the history
  • Loading branch information
joussy committed Jun 16, 2024
1 parent 6864b30 commit 42661b7
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,71 @@
name: Docker
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Build and Publish

on:
push:
branches:
- '**'
# release:
# types: [created]
release:
types: [created]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}



jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Build frontend
run: |
cd client
npm ci
npm run build
- name: Build backend
run: |
cd server
npm ci
- uses: actions/upload-artifact@v4
with:
name: frontend-artifact
path: client/dist

publish-npm:
# if: github.event_name == 'release'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
name: frontend-artifact
path: server/src/public
- name: Build backend
run: |
cd server
npm ci
# - run: |
# cd server
# npm version --no-git-tag-version ${{ github.ref_name }}
# npm publish --allow-same-version
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

publish-docker:
needs: publish-npm
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -60,21 +109,28 @@ jobs:
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
name: frontend-artifact
path: server/src/public

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
context: server
# push: ${{ github.event_name != 'pull_request' }}
push: ${{ false }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
file: Dockerfile.ci

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
Expand Down
61 changes: 0 additions & 61 deletions .github/workflows/npm-publish.yml

This file was deleted.

18 changes: 18 additions & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG NODE_VERSION=20.14.0

FROM node:${NODE_VERSION}-alpine

WORKDIR /usr/src/app

COPY . .

RUN npm install

# Run the application as a non-root user.
USER node

# Expose the port that the application listens on.
EXPOSE 3000

# Run the application.
CMD node bin/www

0 comments on commit 42661b7

Please sign in to comment.