Skip to content

Commit

Permalink
refactor: refactored ci and build
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaile committed Mar 18, 2024
1 parent 1880834 commit 19ed3d3
Show file tree
Hide file tree
Showing 57 changed files with 438 additions and 1,687 deletions.
35 changes: 0 additions & 35 deletions .devcontainer/devcontainer.json

This file was deleted.

25 changes: 11 additions & 14 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,35 @@ LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=pgsql
DB_HOST=pgsql
DB_HOST=database
DB_PORT=5432
DB_DATABASE=phonehome
DB_USERNAME=phonehome
DB_PASSWORD=phonehome

BROADCAST_DRIVER=redis
CACHE_DRIVER=redis
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=memcached
MEMCACHED_HOST=127.0.0.1

REDIS_HOST=redis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@phonehome.localhost"
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

GEOIP_TOKEN=

# Sail configuration
WWWGROUP=1000
WWWUSER=1000
SAIL_XDEBUG_MODE=develop,debug,coverage
SAIL_XDEBUG_CONFIG="client_host=127.0.0.1"
UID=1000
GID=1000
97 changes: 16 additions & 81 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ on:
- cron: "0 5 * * 1"
workflow_call:
workflow_dispatch:

permissions:
contents: read
packages: write

jobs:
build-image:
name: Build images and push to registry
Expand All @@ -19,7 +24,7 @@ jobs:
uses: docker/metadata-action@v4
id: meta-app
with:
bake-target: app
bake-target: app-production
images: |
ghcr.io/${{ github.repository }}-app
tags: |
Expand All @@ -32,7 +37,7 @@ jobs:
uses: docker/metadata-action@v4
id: meta-web
with:
bake-target: web
bake-target: web-production
images: |
ghcr.io/${{ github.repository }}-web
tags: |
Expand All @@ -41,102 +46,32 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
- name: Generate cache tag for app image
uses: docker/metadata-action@v4
id: cache-tag-app
with:
images: |
ghcr.io/${{ github.repository }}-app
tags: |
type=ref,event=branch
type=raw,enable=${{ github.ref_type == 'tag' }},value=${{ github.event.repository.default_branch }}
flavor:
suffix=-cache

- name: Generate cache tag for web image
- name: Generate ns8 image tags
uses: docker/metadata-action@v4
id: cache-tag-web
id: meta-ns8
with:
bake-target: ns8
images: |
ghcr.io/${{ github.repository }}-web
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=raw,enable=${{ github.ref_type == 'tag' }},value=${{ github.event.repository.default_branch }}
flavor:
suffix=-cache
type=semver,pattern={{version}}
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
password: ${{ github.token }}

- uses: docker/bake-action@v3.1.0
with:
targets: release
targets: deploy
files: |
./docker-bake.hcl
${{ steps.meta-app.outputs.bake-file }}
${{ steps.meta-web.outputs.bake-file }}
${{ steps.meta-ns8.outputs.bake-file }}
set: |
*.platform=linux/amd64
app.cache-from=type=registry,ref=${{ steps.cache-tag-app.outputs.tags }}
app.cache-to=type=registry,ref=${{ steps.cache-tag-app.outputs.tags }},mode=max
web.cache-from=type=registry,ref=${{ steps.cache-tag-web.outputs.tags }}
web.cache-to=type=registry,ref=${{ steps.cache-tag-web.outputs.tags }},mode=max
*.cache-to=type=gha,mode=max
push: true

build-deploy:
name: Build NS8 deploy image
runs-on: ubuntu-22.04
needs: build-image
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Generate tags
uses: docker/metadata-action@v4
id: meta
with:
images: |
ghcr.io/nethserver/ns8-phonehome
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
- name: Generate Phonehome image tags
uses: docker/metadata-action@v4
id: phonehome-tags
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build image with buildah
env:
TAGS: ${{ steps.meta.outputs.tags }}
LABELS: ${{ steps.meta.outputs.labels }}
ARGS: |
PHONEHOME_TAG=${{ steps.phonehome-tags.outputs.version }}
PHONEHOME_SERVER_APP=${{ steps.phonehome-tags.outputs.tags }}-app
PHONEHOME_SERVER_WEB=${{ steps.phonehome-tags.outputs.tags }}-web
working-directory: deploy/ns8
run: |
./build-images.sh
- name: Push image to registry
run: |
PUSH_TAGS='${{ steps.meta.outputs.tags }}'
for tag in $PUSH_TAGS; do
podman push "$tag"
done
68 changes: 0 additions & 68 deletions .github/workflows/clean.yml

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ jobs:
uses: ./.github/workflows/build.yml
needs:
- test-app-image
secrets: inherit
36 changes: 17 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
name: Testing
on:
push:
branches:
- "renovate/**"
pull_request:
workflow_call:

permissions:
contents: read
packages: read

jobs:
test-app-image:
name: Test app image
Expand All @@ -13,24 +21,14 @@ jobs:
- name: Create new buildx builder
uses: docker/setup-buildx-action@v2

- name: Generate Image Metadata
uses: docker/metadata-action@v4
id: cache-from-tag
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
images: |
ghcr.io/${{ github.repository }}-app
tags: |
type=ref,event=branch
type=raw,enable=${{ github.event_name == 'pull_request' }},value=${{ github.base_ref }}
flavor: |
latest=false
suffix=-cache
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- uses: docker/bake-action@v3.1.0
with:
files: |
./docker-bake.hcl
targets: testing
set: |
*.platform=linux/amd64
*.cache-from=type=registry,ref=${{ steps.cache-from-tag.outputs.tags }}
- name: Run testing
run: |
cp .env.example .env
docker compose run --rm --build testing
Loading

0 comments on commit 19ed3d3

Please sign in to comment.