diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..b4567939 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: CI + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: Set environment up + run: | + docker compose pull + docker compose build + docker compose run --rm client npm install + + - name: Run specs + env: + JVM_OPTS: -Xmx3200m + TEST_DATABASE_URL: jdbc:postgresql://db/planwise?user=planwise&password=planwise + run: | + docker compose run --rm -e JVM_OPTS -e TEST_DATABASE_URL app lein test + docker compose run --rm client npm run test + docker compose run --rm app lein check-format + + build: + needs: test + runs-on: ubuntu-22.04 + env: + DOCKER_REPOSITORY: 'instedd/planwise' + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} + steps: + - uses: actions/checkout@v4 + - name: Build image & push to Docker Hub + run: ./build.sh diff --git a/Dockerfile b/Dockerfile index 49488adb..8d4131d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,6 +48,9 @@ ENV BIN_PATH /app/bin/ COPY --from=build /app/target/uberjar/planwise-standalone.jar /app/lib/ ENV JAR_PATH /app/lib/planwise-standalone.jar +# Add app version file +COPY --from=build /app/resources/planwise/version /app/VERSION + # Expose JNI libs to app ENV LD_LIBRARY_PATH=/usr/lib/jni diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..b652acf7 --- /dev/null +++ b/build.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -eo pipefail + +source <(curl -s https://raw.githubusercontent.com/manastech/ci-docker-builder/d3406587def914918666ef41c0637d6b739fdf7d/build.sh) + +dockerSetup +echo $VERSION > VERSION +echo $VERSION > resources/planwise/version + +dockerBuildAndPush +# FIXME: build & push mapcache +# FIXME: build & push mapserver +# FIXME: build & push tools