Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Automatic Docker builds on tagged releases and PRs #427

Merged
merged 3 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .dockerfiles/www/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
server {
listen 80;
listen [::]:80;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
167 changes: 154 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
name: Build

on:
schedule:
- cron: '0 0 * * *' # Every day at midnight
push:
pull_request:
paths:
- '.github/workflows/build.yml'
# Build when a fundamental package change has occured
- 'package.json'
branches:
- main
- develop
push:
branches:
- main
- develop
tags:
- v*
schedule:
- cron: '0 16 * * *' # Every day at 16:00 UTC (~09:00 PT)

jobs:
build:
name: Build the frontend releasable package
name: Build releasable package
runs-on: ubuntu-latest

steps:
Expand All @@ -22,11 +27,8 @@ jobs:
with:
node-version: '15.x'

- name: Install dependencies
run: npm install --legacy-peer-deps

- name: Compile build
run: npm run build -- --env=houston=relative
- name: Install dependencies and compile
run: ./scripts/build.npm.sh

- name: Package the build
run: |
Expand All @@ -39,3 +41,142 @@ jobs:
path: codex-frontend.tar.gz
# default:
# retention-days: 90

deploy:
name: Docker image build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
if: github.event_name == 'schedule'
with:
ref: develop
bluemellophone marked this conversation as resolved.
Show resolved Hide resolved

- uses: actions/checkout@v2
if: github.event_name != 'schedule'

- uses: docker/setup-qemu-action@v1
name: Set up QEMU
id: qemu
with:
image: tonistiigi/binfmt:latest
platforms: all

- uses: docker/setup-buildx-action@v1
name: Set up Docker Buildx
id: buildx

- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

# Build images
- name: Build Codex
run: |
./scripts/buildx.docker.sh

# Log into container registries
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: wildmebot
password: ${{ secrets.WBIA_WILDMEBOT_DOCKER_HUB_TOKEN }}

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

# Push tagged image (version tag + latest) to registries
- name: Tagged Docker Hub
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
run: |
VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##')
./scripts/buildx.docker.sh -t ${VERSION}
./scripts/buildx.docker.sh -t latest

- name: Tagged GHCR
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
run: |
VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##')
./scripts/buildx.docker.sh -t ${VERSION} -r ghcr.io/wildmeorg/codex-frontend
./scripts/buildx.docker.sh -t latest -r ghcr.io/wildmeorg/codex-frontend

# Push stable image (main tag) to registries
- name: Stable Docker Hub
if: github.ref == 'refs/heads/main'
run: |
./scripts/buildx.docker.sh -t main

- name: Stable GHCR
if: github.ref == 'refs/heads/main'
run: |
./scripts/buildx.docker.sh -t main -r ghcr.io/wildmeorg/codex-frontend

# Push bleeding-edge image (develop tag) to registries
- name: Bleeding Edge Docker Hub
if: github.ref == 'refs/heads/develop'
run: |
./scripts/buildx.docker.sh -t develop

- name: Bleeding Edge GHCR
if: github.ref == 'refs/heads/develop'
run: |
./scripts/buildx.docker.sh -t develop -r ghcr.io/wildmeorg/codex-frontend

# Push nightly image (nightly tag) to registries
- name: Nightly Docker Hub
if: github.event_name == 'schedule'
run: |
./scripts/buildx.docker.sh -t nightly

- name: Nightly GHCR
if: github.event_name == 'schedule'
run: |
./scripts/buildx.docker.sh -t nightly -r ghcr.io/wildmeorg/codex-frontend

# Notify status in Slack
- name: Slack Notification
if: ${{ failure() && github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
uses: rtCamp/action-slack-notify@master
env:
SLACK_CHANNEL: dev-houston
SLACK_COLOR: '#FF0000'
SLACK_ICON: https://avatars.slack-edge.com/2020-03-02/965719891842_db87aa21ccb61076f236_44.png
SLACK_MESSAGE: 'Tagged / Latest Docker build of Codex Frontend failed :sob:'
SLACK_USERNAME: "GitHub CI"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

- name: Slack Notification
if: ${{ failure() && github.ref == 'refs/heads/main' }}
uses: rtCamp/action-slack-notify@master
env:
SLACK_CHANNEL: dev-houston
SLACK_COLOR: '#FF0000'
SLACK_ICON: https://avatars.slack-edge.com/2020-03-02/965719891842_db87aa21ccb61076f236_44.png
SLACK_MESSAGE: 'Stable Docker build of Codex Frontend failed :sob:'
SLACK_USERNAME: "GitHub CI"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

- name: Slack Notification
if: ${{ failure() && github.ref == 'refs/heads/develop' }}
uses: rtCamp/action-slack-notify@master
env:
SLACK_CHANNEL: dev-houston
SLACK_COLOR: '#FF0000'
SLACK_ICON: https://avatars.slack-edge.com/2020-03-02/965719891842_db87aa21ccb61076f236_44.png
SLACK_MESSAGE: 'Bleeding Edge Docker build of Codex Frontend failed :sob:'
SLACK_USERNAME: "GitHub CI"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

- name: Slack Notification
if: ${{ failure() && github.event_name == 'schedule' }}
uses: rtCamp/action-slack-notify@master
env:
SLACK_CHANNEL: dev-houston
SLACK_COLOR: '#FF0000'
SLACK_ICON: https://avatars.slack-edge.com/2020-03-02/965719891842_db87aa21ccb61076f236_44.png
SLACK_MESSAGE: 'Nightly Docker build of Codex Frontend failed :sob:'
SLACK_USERNAME: "GitHub CI"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
49 changes: 0 additions & 49 deletions .github/workflows/nightly.yml

This file was deleted.

15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:lts as org.wildme.codex.frontend.build

COPY . /code

WORKDIR /code

RUN set -ex \
&& ./scripts/build.npm.sh

##########################################################################################
FROM nginx:alpine as org.wildme.codex.frontend.deploy

COPY --from=org.wildme.codex.frontend.build /code/dist /usr/share/nginx/html

COPY ./.dockerfiles/www/default.conf /etc/nginx/conf.d/default.conf
14 changes: 0 additions & 14 deletions prod/Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion prod/README.md

This file was deleted.

92 changes: 0 additions & 92 deletions prod/default.conf

This file was deleted.

4 changes: 4 additions & 0 deletions scripts/build.npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

npm install --legacy-peer-deps
npm run build -- --env=houston=relative
Loading