Skip to content

Commit

Permalink
added ghcr build and build scripts to package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
popenc committed Apr 23, 2024
1 parent f8dcd2f commit 3d8160a
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**/node_modules
**/dist
.git
.gitignore
**/Dockerfile
**/docker-compose.yml
**/.env
**/secrets/
75 changes: 75 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Create and publish a Docker image

on: push

env:
REGISTRY: ghcr.io
ANGULAR_IMAGE: quanted/vb-angular
NGINX_IMAGE: quanted/vb-nginx

jobs:
build-angular:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

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

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

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.ANGULAR_IMAGE }}

- name: Build and push Cyanweb Angular/Node Docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
build-args: env=kube
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

build-nginx:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: build-angular
steps:
- name: Checkout repository
uses: actions/checkout@v2

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

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.NGINX_IMAGE }}

- name: Build and push Cyanweb Nginx Docker image
uses: docker/build-push-action@v2
with:
context: .
file: docker/nginx/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: config=nginx.conf
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM node:lts-alpine

# Build-time variables (see package.json)
ARG env=standalone

# Env vars for angular unit tests and bypassing angular CLI install prompt:
ENV CHROME_BIN=/usr/bin/chromium-browser \
CHROME_PATH=/usr/lib/chromium/ \
NG_CLI_ANALYTICS=false

ENV APP_USER=www-data

COPY . /app

# COPY docker/ /docker

WORKDIR /app

RUN apk update && \
apk upgrade && \
apk add chromium

# RUN npm install --force
RUN npm install
RUN npm run build:$env

RUN adduser -S $APP_USER -G $APP_USER

# RUN chown -R $APP_USER:$APP_USER /app /docker
RUN chown -R $APP_USER:$APP_USER /app

# Runs as non-root user "www-data"
USER $APP_USER
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build-kube": "ng build --baseHref=/vb --outputPath=../vb_django/vb_django/static",
"build-kube": "ng build --baseHref=/vb --q=../vb_django/vb_django/static",
"build:orig": "ng build --baseHref=/vb",
"build:standalone": "ng build --prod --outputPath=dist",
"build:kube": "ng build --prod --baseHref=/vbweb/ --outputPath=dist/vbweb --outputHashing=bundles",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
Expand Down

0 comments on commit 3d8160a

Please sign in to comment.