Skip to content

Commit

Permalink
Merge pull request #19 from startersclan/enhancement/ci-add-test-for-…
Browse files Browse the repository at this point in the history
…production-builds

Enhancement (ci): Add test for production builds
  • Loading branch information
leojonathanoh committed Oct 31, 2023
2 parents 2e667ef + 11fddb6 commit 3391c59
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ci-master-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:

jobs:
test:
strategy:
matrix:
testenv:
- dev
- prod
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -46,7 +51,12 @@ jobs:
- name: Test (integration)
run: |
set -eu
docker compose up --build -d
if [ "${{ matrix.testenv }}" == 'dev' ]; then
docker compose up --build -d
fi
if [ "${{ matrix.testenv }}" == 'prod' ]; then
docker compose -f docker-compose.example.yml -f docker-compose.example.build.yml up --build -d
fi
docker compose -f docker-compose.test.yml up
build:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ docker exec -it $( docker compose ps -q db ) sh
docker compose -f docker-compose.test.yml up

# Test production builds locally
docker build -t startersclan/hlstatsx-community-edition:daemon -f Dockerfile.daemon .
docker build -t startersclan/hlstatsx-community-edition:web -f Dockerfile.web .
docker compose -f docker-compose.example.yml -f docker-compose.example.build.yml up --build

# Dump the DB
docker exec $( docker compose ps -q db ) mysqldump -uroot -proot hlstatsxce | gzip > hlstatsxce.sql.gz
Expand Down
42 changes: 42 additions & 0 deletions docker-compose.example.build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This is a docker compose override file, for testing production builds
version: '2.2'
services:
daemon:
build:
dockerfile: Dockerfile.daemon
context: .
target: prod
cache_from:
- type=local,src=/tmp/.buildx-cache-daemon
cache_to:
- type=local,dest=/tmp/.buildx-cache-daemon,mode=max

awards:
build:
dockerfile: Dockerfile.daemon
context: .
target: prod
cache_from:
- type=local,src=/tmp/.buildx-cache-daemon
cache_to:
- type=local,dest=/tmp/.buildx-cache-daemon,mode=max

web:
build:
dockerfile: Dockerfile.web
context: .
target: prod
cache_from:
- type=local,src=/tmp/.buildx-cache-web
cache_to:
- type=local,dest=/tmp/.buildx-cache-web,mode=max

heatmaps:
build:
dockerfile: Dockerfile.web
context: .
target: prod
cache_from:
- type=local,src=/tmp/.buildx-cache-web
cache_to:
- type=local,dest=/tmp/.buildx-cache-web,mode=max
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ services:
build:
dockerfile: Dockerfile.web
context: .
target: base
target: dev
cache_from:
- type=local,src=/tmp/.buildx-cache-web
cache_to:
Expand Down

0 comments on commit 3391c59

Please sign in to comment.