This repository has been archived by the owner on Mar 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Docker support and improve error handling in Application.kt
- Loading branch information
Showing
12 changed files
with
253 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: Push | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- stable | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'adopt' | ||
|
||
- name: Tests | ||
run: mvn test | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
|
||
needs: | ||
- test | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'adopt' | ||
|
||
- name: Build | ||
run: mvn -B package -DskipTests | ||
|
||
docker: | ||
runs-on: ubuntu-latest | ||
|
||
needs: | ||
- build | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: registry.ziedelth.fr:5000 | ||
username: ziedelth | ||
password: ${{ secrets.REGISTRY_PASSWORD }} | ||
|
||
- name: Build and push snapshot | ||
uses: docker/build-push-action@v5 | ||
if: github.ref == 'refs/heads/master' | ||
with: | ||
context: . | ||
push: true | ||
tags: registry.ziedelth.fr:5000/jais-api:snapshot | ||
|
||
- name: Build and push production | ||
uses: docker/build-push-action@v5 | ||
if: github.ref == 'refs/heads/stable' | ||
with: | ||
context: . | ||
push: true | ||
tags: registry.ziedelth.fr:5000/jais-api:latest | ||
|
||
release: | ||
if: github.ref == 'refs/heads/stable' | ||
name: Release | ||
runs-on: ubuntu-latest | ||
|
||
needs: | ||
- docker | ||
|
||
steps: | ||
- name: Install SSH KEY | ||
uses: shimataro/ssh-key-action@v2 | ||
with: | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
known_hosts: 'just-a-placeholder-so-we-dont-get-errors' | ||
|
||
- name: Adding Known Hosts | ||
run: ssh-keyscan -p 2222 -H ${{ secrets.SSH_HOST_IP }} >> ~/.ssh/known_hosts | ||
|
||
- name: SSH Commands | ||
run: | | ||
ssh -C -p 2222 ${{ secrets.SSH_DESTINATION }} "docker pull localhost:5000/jais-api:latest && cd ${{ secrets.SSH_FOLDER }} && docker compose down jais-api && docker compose up jais-api -d" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM maven:3.9.4-amazoncorretto-17 AS build | ||
COPY . /app | ||
WORKDIR /app | ||
RUN mvn clean package -DskipTests | ||
|
||
FROM amazoncorretto:17-alpine | ||
COPY --from=build /app/target/api-1.0.0-jar-with-dependencies.jar /app/api.jar | ||
COPY --from=build /app/data/ /app/data/ | ||
|
||
RUN apk update && apk add gcompat opencv-dev | ||
EXPOSE 8080 | ||
WORKDIR /app | ||
ENTRYPOINT ["java", "-jar", "api.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE hibernate-configuration PUBLIC | ||
"-//Hibernate/Hibernate Configuration DTD 3.0//EN" | ||
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> | ||
<hibernate-configuration> | ||
<session-factory> | ||
<!-- Database connection settings --> | ||
<property name="connection.url">jdbc:postgresql://localhost:5432/jais</property> | ||
<property name="connection.username">postgres</property> | ||
<property name="connection.password">mysecretpassword</property> | ||
<property name="show_sql">false</property> | ||
<property name="hibernate.hbm2ddl.auto">update</property> | ||
<property name="hibernate.current_session_context_class">org.hibernate.context.internal.ThreadLocalSessionContext</property> | ||
</session-factory> | ||
</hibernate-configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
version: '3.8' | ||
services: | ||
jais-db: | ||
image: postgres:16-alpine | ||
restart: always | ||
container_name: jais-db | ||
environment: | ||
POSTGRES_PASSWORD: "mysecretpassword" | ||
POSTGRES_USER: postgres | ||
POSTGRES_DB: jais | ||
healthcheck: | ||
test: ["CMD", "pg_isready", "-U", "postgres"] | ||
volumes: | ||
- ./tmp_data.sql:/docker-entrypoint-initdb.d/dummy_dump.sql | ||
jais-api: | ||
image: localhost:5000/jais-api:latest | ||
ports: | ||
- "8080:8080" | ||
restart: on-failure | ||
container_name: jais-api | ||
depends_on: | ||
jais-db: | ||
condition: service_healthy | ||
environment: | ||
DATABASE_URL: jdbc:postgresql://jais-db:5432/jais | ||
DATABASE_USERNAME: postgres | ||
DATABASE_PASSWORD: "mysecretpassword" | ||
SEND_NOTIFICATIONS: "false" | ||
volumes: | ||
- jais-api-data:/app/data | ||
jais-scraper: | ||
image: localhost:5000/jais-scraper:latest | ||
restart: on-failure | ||
container_name: jais-scraper | ||
depends_on: | ||
jais-api: | ||
condition: service_started | ||
environment: | ||
API_URL: http://jais-api:8080/ | ||
volumes: | ||
- jais-scraper-data:/app/data | ||
jais-website: | ||
image: localhost:5000/jais-website:latest | ||
ports: | ||
- "8081:80" | ||
restart: on-failure | ||
container_name: jais-website | ||
depends_on: | ||
jais-api: | ||
condition: service_started | ||
volumes: | ||
- jais-website-data:/usr/local/apache2/htdocs/attachments/ | ||
|
||
volumes: | ||
jais-api-data: | ||
name: jais-api-data | ||
jais-scraper-data: | ||
name: jais-scraper-data | ||
jais-website-data: | ||
name: jais-website-data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters