From 4a1815079e772a90e07d704f45f7f1fde9bbac84 Mon Sep 17 00:00:00 2001 From: Ilmari Vacklin Date: Wed, 11 Sep 2024 10:00:03 +0300 Subject: [PATCH] feat: add CI build and Dockerfile --- .dockerignore | 3 +++ .github/workflows/build.yml | 32 ++++++++++++++++++++++++++++++++ Dockerfile | 9 +++++++++ 3 files changed, 44 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/build.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..0e49fd4aa --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +target +node_modules +infra diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..949479e9a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,32 @@ +name: Build + +on: + push: + branches: + - main + - feat/cdk # remove before merging + +jobs: + build: + name: Build + + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + env: + tag: todo + + steps: + - uses: actions/checkout@v4 + - run: | + tag=ghcr.io/opetushallitus/koto-rekisteri:$GITHUB_SHA + docker build -t $tag . + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + docker push $tag + - run: | + npm ci + npx cdk deploy --all + working-directory: infra diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..3aa8d91fa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM maven:3.9.9-amazoncorretto-21 + +WORKDIR /kitu + +COPY . . + +RUN mvn package -DskipTests + +ENTRYPOINT ["java", "-jar", "target/kitu-0.0.1-SNAPSHOT.jar"]