Skip to content

Commit

Permalink
setup container builds for application
Browse files Browse the repository at this point in the history
  • Loading branch information
marcolarosa committed Nov 3, 2023
1 parent 97239b8 commit c551a3e
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build packages and publish to Github Container Registry

on:
push:
tags:
- '*'

env:
REGISTRY: ghcr.io

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3
with:
node-version: 18

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build the containers
run: ./build-container.sh ${{ github.ref_name }}
shell: bash
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM nginx:latest
LABEL org.opencontainers.image.source=https://github.com/CoEDL/50words.online
LABEL org.opencontainers.image.description="The 50 words application"
LABEL org.opencontainers.image.licenses=GPLv3

# RUN apt-get update && apt-get install -y nginx-extras
RUN rm /etc/nginx/conf.d/default.conf

COPY ./dist/ /srv/50words/www/

CMD ["nginx", "-g", "daemon off;"]
9 changes: 9 additions & 0 deletions build-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

VERSION=$1
echo "Building $VERSION"

# build the 50words application container
npm run build:production
docker build --push --rm \
-t ghcr.io/coedl/50words.online:latest .
19 changes: 19 additions & 0 deletions version-and-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

if [ "$#" != "1" ] ; then
echo "Usage: $0 [minor | patch]"
exit -1
fi

if [[ $1 != 'minor' && $1 != 'patch' ]] ; then
echo "Usage: $0 [minor | patch]"
exit -1
fi

# version the code
version=$(npm version --no-git-tag-version $1)
git tag $version
git commit -a -m "tag and bump version"

# push it to github to trigger container builds
git push origin master --tags

0 comments on commit c551a3e

Please sign in to comment.