Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Toto-hitori committed Mar 12, 2024
2 parents f4560de + cf380d0 commit 10c5e82
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 16 deletions.
39 changes: 33 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Deploy on release
on:
release:
types: [published]

jobs:
unit-tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -60,31 +59,59 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: api
buildargs: API_URI
buildargs: |
DATABASE_USER
DATABASE_PASSWORD
JWT_SECRET
docker-push-webapp:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [ e2e-tests ]
steps:

- uses: actions/checkout@v4

- name: Create .env file
run: echo "REACT_APP_API_ENDPOINT=http://${{ secrets.DEPLOY_HOST }}:8080" > webapp/.env

- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
env:
API_URI: http://${{ secrets.DEPLOY_HOST }}:8080
REACT_APP_API_ENDPOINT: http://${{ secrets.DEPLOY_HOST }}:8080
teamname: wiq_en2b
with:
name: arquisoft/wiq_en2b/webapp
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: webapp
buildargs: API_URI
buildargs: |
REACT_APP_API_ENDPOINT
docker-push-question-generator:
runs-on: ubuntu-latest
needs: [ e2e-tests ]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
env:
DATABASE_USER: ${{ secrets.DATABASE_USER }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
with:
name: arquisoft/wiq_en2b/question-generator
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questiongenerator
buildargs: |
DATABASE_USER
DATABASE_PASSWORD
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
needs: [docker-push-api, docker-push-webapp]
needs: [docker-push-api, docker-push-webapp, docker-push-question-generator]
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
Expand All @@ -105,4 +132,4 @@ jobs:
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> .env
echo "API_URI=http://${{ secrets.DEPLOY_HOST }}:8080" >> .env
docker compose --profile prod down
docker compose --profile prod up -d
docker compose --profile prod up -d --pull always
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ We aim to create a platform that not only challenges your knowledge but also spa

## What Sets WIQ Apart
🤔 Thoughtful Questions: Dive into a world of intriguing and diverse questions, all generated procedurally using WikiData.
🌐 Encourage to improve: WIQ lets you keep track of your score to see in which areas you need to improve.
🌐 Encourage to improve: WIQ lets you keep track of your score to see in which areas you need to improve.

😭 It works! after the final version final re-final (FINAL) true (final) (hotfix)

## Features
🏆 Adaptable difficulty: You can adjust the difficulty to push your limits.
Expand Down
1 change: 0 additions & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM maven:3.8.1-openjdk-17 AS build
# Compile api
WORKDIR /api
COPY . /api
WORKDIR /api
RUN mvn install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
import org.springframework.data.jpa.repository.Query;

public interface QuestionRepository extends JpaRepository<Question,Long> {
@Query(value = "SELECT q FROM questions WHERE q.language=?1 ORDER BY RANDOM() LIMIT 1", nativeQuery = true)
@Query(value = "SELECT * FROM questions WHERE language=?1 ORDER BY RANDOM() LIMIT 1", nativeQuery = true)
Question findRandomQuestion(String lang);
}
28 changes: 25 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,47 @@ services:

api:
container_name: api-${teamname:-defaultASW}
image: api:latest
image: ghcr.io/arquisoft/wiq_en2b/api:latest
profiles: [ "dev", "prod" ]
build:
context: ./api
args:
DATABASE_USER: ${DATABASE_USER}
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
JWT_SECRET: ${JWT_SECRET}
environment:
- DATABASE_URL=jdbc:postgresql://WIQ_DB:5432/wiq
- DATABASE_USER=${DATABASE_USER}
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
- JWT_SECRET=${JWT_SECRET}
networks:
- mynetwork
ports:
- "8080:8080"

question-generator:
container_name: question-generator-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_en2b/question-generator:latest
profiles: [ "dev", "prod" ]
build:
context: ./questiongenerator
args:
DATABASE_USER: ${DATABASE_USER}
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
environment:
- DATABASE_URL=jdbc:postgresql://WIQ_DB:5432/wiq
- DATABASE_USER=${DATABASE_USER}
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
networks:
- mynetwork

webapp:
container_name: webapp-${teamname:-defaultASW}
image: webapp:latest
image: ghcr.io/arquisoft/wiq_en2b/webapp:latest
profiles: [ "dev", "prod" ]

build:
args:
REACT_APP_API_ENDPOINT: ${API_URI}
context: ./webapp
environment:
- REACT_APP_API_ENDPOINT=${API_URI}
Expand Down
19 changes: 19 additions & 0 deletions questiongenerator/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM maven:3.8.1-openjdk-17 AS build
LABEL authors="dario"
# Compile api
COPY . /questiongenerator
WORKDIR /questiongenerator
RUN mvn install
RUN mvn clean package

FROM amazoncorretto:17 AS runtime
# Copy the compiled jar file from the build stage
ARG DATABASE_USER
ARG DATABASE_PASSWORD

# Set environment variables
ENV DATABASE_URL jdbc:postgresql://WIQ_DB:5432/wiq
ENV DATABASE_USER $DATABASE_USER
ENV DATABASE_PASSWORD $DATABASE_PASSWORD
COPY --from=build /questiongenerator/target/QuestionGenerator-1.0-SNAPSHOT-jar-with-dependencies.jar app.jar
ENTRYPOINT ["java","-jar","app.jar"]
40 changes: 36 additions & 4 deletions questiongenerator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,49 @@
<scope>runtime</scope>
<version>42.6.1</version>
</dependency>

<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<type>maven-plugin</type>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<source>11</source>
<target>11</target>
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
Expand Down

0 comments on commit 10c5e82

Please sign in to comment.