Skip to content

Commit

Permalink
chore: add action to build and deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
astappiev committed Sep 20, 2023
1 parent 4b3ec2b commit 783a899
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 214 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/target
**/.env
.idea
57 changes: 57 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: publish

on:
push:
branches: [ "main" ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
name: publish image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

deploy:
needs: build-and-push-image
name: deploy image
runs-on: ubuntu-latest

steps:
- name: Install ssh keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.DEPLOY_PRIVATE_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} > ~/.ssh/known_hosts
ssh-keyscan -H ${{ secrets.DEPLOY_JUMP_HOST }} > ~/.ssh/known_hosts
- name: Connect and pull
run: ssh -J ${{ secrets.DEPLOY_JUMP_USERNAME }}@${{ secrets.DEPLOY_JUMP_HOST }} ${{ secrets.DEPLOY_USERNAME }}@${{ secrets.DEPLOY_HOST }} \
"cd ${{ secrets.DEPLOY_PATH }} && docker compose pull && docker compose up -d && exit"

- name: Cleanup
run: rm -rf ~/.ssh
50 changes: 0 additions & 50 deletions .gitlab-ci.yml

This file was deleted.

24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-17 AS build
COPY --chown=quarkus:quarkus . /code
USER quarkus

WORKDIR /code
RUN ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:go-offline
RUN ./mvnw package -DskipTests -Dnative

## Stage 2 : create the docker final image
FROM quay.io/quarkus/quarkus-micro-image:2.0 AS final
WORKDIR /work/
COPY --from=build /code/interweb-server/target/*-runner /work/application

# set up permissions for user `1001`
RUN chmod 775 /work /work/application \
&& chown -R 1001 /work \
&& chmod -R "g+rwX" /work \
&& chown -R 1001:root /work

EXPOSE 8080
USER 1001

CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
5 changes: 0 additions & 5 deletions interweb-server/.dockerignore

This file was deleted.

95 changes: 0 additions & 95 deletions interweb-server/src/main/docker/Dockerfile.jvm

This file was deleted.

27 changes: 0 additions & 27 deletions interweb-server/src/main/docker/Dockerfile.native

This file was deleted.

30 changes: 0 additions & 30 deletions interweb-server/src/main/docker/Dockerfile.native-micro

This file was deleted.

16 changes: 9 additions & 7 deletions interweb-server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ quarkus.hibernate-orm.log.sql=true

quarkus.health.openapi.included=false
quarkus.smallrye-jwt.enabled=true
quarkus.native.resources.includes=publicKey.pem,privateKey.pem

smallrye.jwt.encrypt.key=publicKey.pem
smallrye.jwt.sign.key.location=privateKey.pem
smallrye.jwt.new-token.issuer=https://l3s.de/interweb
smallrye.jwt.new-token.lifespan=7200
quarkus.jwt.issuer=https://l3s.de/interweb
quarkus.jwt.public.key=
quarkus.jwt.private.key=

mp.jwt.verify.publickey.location=publicKey.pem
mp.jwt.verify.issuer=https://l3s.de/interweb
smallrye.jwt.encrypt.key=${quarkus.jwt.public.key}
smallrye.jwt.sign.key=${quarkus.jwt.private.key}
smallrye.jwt.new-token.issuer=${quarkus.jwt.issuer}
smallrye.jwt.new-token.lifespan=7200
mp.jwt.verify.publickey=${quarkus.jwt.public.key}
mp.jwt.verify.issuer=${quarkus.jwt.issuer}

# OpenAPI, Swagger
quarkus.swagger-ui.always-include=true
Expand Down

0 comments on commit 783a899

Please sign in to comment.