Compare commits
4 Commits
main
...
40f983980d
| Author | SHA1 | Date | |
|---|---|---|---|
| 40f983980d | |||
| 2a50edc41d | |||
| 70f6b0c7b2 | |||
| adfe4dcbc2 |
139
.github/workflows/deploy-docker-to-tst.yml
vendored
Normal file
139
.github/workflows/deploy-docker-to-tst.yml
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
name: Docker Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
tags:
|
||||
- "docker-build-*"
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Stap 1: Code ophalen
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# Stap 2: Versienummer ophalen uit pom.xml en opslaan als artifact
|
||||
- name: Extract Quarkus version from pom.xml
|
||||
run: |
|
||||
VERSION=$(xmlstarlet sel -t -v "/project/version" pom.xml)
|
||||
echo $VERSION > version.txt
|
||||
- name: Save version as artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: version
|
||||
path: version.txt
|
||||
|
||||
# Stap 3: Notify Mattermost via Bot (Build gestart)
|
||||
- name: Notify Mattermost via Bot
|
||||
env:
|
||||
VERSION: ${{ env.VERSION }}
|
||||
REPO: ${{ gitea.repository }}
|
||||
BRANCH: ${{ gitea.ref }}
|
||||
MATTERMOST_BOT_TOKEN: ${{ secrets.MATTERMOST_BOT_TOKEN }}
|
||||
run: |
|
||||
curl --fail -X POST -H "Authorization: Bearer $MATTERMOST_BOT_TOKEN" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"channel_id": "9a8obynkd7rctk6qf8rfe6oppy",
|
||||
"message": "@all 🚀 *Build gestart!* Een nieuwe build ['"$VERSION"'-SNAPSHOT] is begonnen voor de repository *'"$REPO"'* op branch *'"$BRANCH"'*."
|
||||
}' \
|
||||
https://mattermost.melvanveen.nl/api/v4/posts
|
||||
|
||||
# Stap 4: Inloggen bij Docker Hub
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
# Stap 5: Quarkus JAR bouwen (via Maven) en Docker-image bouwen
|
||||
- name: Build the Quarkus JAR and Docker image
|
||||
run: |
|
||||
VERSION=$(cat version.txt)
|
||||
mvn clean package -DskipTests
|
||||
docker buildx build . --file Dockerfile --tag veenm/paypoint-backend-jvm:$VERSION-SNAPSHOT --platform linux/amd64
|
||||
|
||||
# Stap 6: Docker-image pushen naar Docker Hub (huidige versie tag)
|
||||
- name: Push the Docker image (version-snapshot)
|
||||
run: |
|
||||
VERSION=$(cat version.txt)
|
||||
docker push veenm/paypoint-backend-jvm:$VERSION-SNAPSHOT
|
||||
|
||||
deploy:
|
||||
needs: build-and-push
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Stap 1: Artifact ophalen
|
||||
- name: Download version artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: version
|
||||
|
||||
# Stap 2: Lees versie uit het artifact
|
||||
- name: Read version
|
||||
id: read_version
|
||||
run: echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV
|
||||
|
||||
- name: Inject private key into resources
|
||||
run: |
|
||||
mkdir -p src/main/resources
|
||||
echo "${{ secrets.PRIVATE_KEY }}" > src/main/resources/privateKey.pem
|
||||
chmod 600 src/main/resources/privateKey.pem
|
||||
|
||||
- name: Inject public key into resources
|
||||
run: |
|
||||
mkdir -p src/main/resources
|
||||
echo "${{ secrets.PUBLIC_KEY }}" > src/main/resources/publicKey.pem
|
||||
chmod 600 src/main/resources/publicKey.pem
|
||||
|
||||
# Stap 3: Maak verbinding via SSH naar de Alpine server en update de container
|
||||
- name: SSH into Alpine and update Docker container
|
||||
uses: appleboy/ssh-action@v0.1.10
|
||||
with:
|
||||
host: ${{ secrets.ALPINE_HOST }}
|
||||
username: ${{ secrets.ALPINE_USER }}
|
||||
password: ${{ secrets.ALPINE_PASSWORD }}
|
||||
script: |
|
||||
VERSION=${{ env.VERSION }}
|
||||
echo "Gekozen versie: $VERSION-SNAPSHOT"
|
||||
|
||||
# Stop en verwijder de huidige container
|
||||
docker stop paypoint-backend || true
|
||||
docker rm paypoint-backend || true
|
||||
|
||||
# Haal de nieuwste image binnen
|
||||
docker pull veenm/paypoint-backend-jvm:$VERSION-SNAPSHOT
|
||||
|
||||
# Start een nieuwe container
|
||||
docker run -d --name paypoint-backend --restart unless-stopped -p 15000:8080 \
|
||||
-e DB_HOST=${{ secrets.ALPINE_HOST }} \
|
||||
-e DB_PORT=${{ secrets.DB_PORT_TEST }} \
|
||||
-e DB_USERNAME=${{ secrets.DB_USERNAME_TEST }} \
|
||||
-e DB_PASSWORD=${{ secrets.DB_PASSWORD_TEST }} \
|
||||
-e CORS_ORIGINS=${{ secrets.CORS_ORIGINS_TEST }} \
|
||||
-e MAILER_FROM=${{ secrets.MAILER_FROM }} \
|
||||
-e MAILER_HOST=${{ secrets.MAILER_HOST }} \
|
||||
-e MAILER_PORT=${{ secrets.MAILER_PORT }} \
|
||||
-e MAILER_USERNAME=${{ secrets.MAILER_USERNAME }} \
|
||||
-e MAILER_PASSWORD=${{ secrets.MAILER_PASSWORD }} \
|
||||
veenm/paypoint-backend-jvm:$VERSION-SNAPSHOT
|
||||
|
||||
# Opruimen oude images
|
||||
docker image prune -f
|
||||
|
||||
# Stap 4: Notify Mattermost via Bot (Build is geslaagd)
|
||||
- name: Notify Mattermost via Bot
|
||||
env:
|
||||
VERSION: ${{ env.VERSION }}
|
||||
run: |
|
||||
curl --fail -X POST -H "Authorization: Bearer $MATTERMOST_BOT_TOKEN" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"channel_id": "9a8obynkd7rctk6qf8rfe6oppy",
|
||||
"message": "@all ✅ *Build is geslaagd!* Versie '"$VERSION"'-SNAPSHOT staat klaar op https://test-paypoint.melvanveen.nl"
|
||||
}' \
|
||||
https://mattermost.melvanveen.nl/api/v4/posts
|
||||
4
pom.xml
4
pom.xml
@@ -84,6 +84,10 @@
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-smallrye-openapi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>at.favre.lib</groupId>
|
||||
<artifactId>bcrypt</artifactId>
|
||||
|
||||
@@ -2,13 +2,8 @@ package nl.veenm.paypoint.repository;
|
||||
|
||||
import io.quarkus.hibernate.orm.panache.PanacheRepository;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import nl.veenm.paypoint.domain.Appointment;
|
||||
import nl.veenm.paypoint.domain.Company;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ApplicationScoped
|
||||
public class CompanyRepository implements PanacheRepository<Company> {
|
||||
}
|
||||
|
||||
@@ -37,12 +37,15 @@ public class AppointmentResource {
|
||||
return appointmentService.getAppointmentsByDate(start, companyId);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/recent/{id}")
|
||||
public Appointment getMostRecentAppointment(@PathParam("id") Long userId) {
|
||||
return appointmentService.getMostRecentByUserId(userId);
|
||||
}
|
||||
|
||||
//TODO: Deze werkend maken
|
||||
|
||||
// @GET
|
||||
// @Produces(MediaType.APPLICATION_JSON)
|
||||
// @Path("/recent/{id}")
|
||||
// public Appointment getMostRecentAppointment(@PathParam("id") Long userId) {
|
||||
// return appointmentService.getMostRecentByUserId(userId);
|
||||
// }
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@@ -56,8 +59,7 @@ public class AppointmentResource {
|
||||
public Response addAppointment(Appointment appointment) {
|
||||
JsonNumber companyIdJson = jwt.getClaim("company_id");
|
||||
Long companyId = companyIdJson.longValue();
|
||||
appointmentService.add(appointment, companyId);
|
||||
return Response.ok().build();
|
||||
return Response.ok(appointmentService.add(appointment, companyId)).build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@@ -70,7 +72,6 @@ public class AppointmentResource {
|
||||
@PUT
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Response updateAppointment(Appointment appointment) {
|
||||
appointmentService.update(appointment);
|
||||
return Response.ok().build();
|
||||
return Response.ok(appointmentService.update(appointment)).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package nl.veenm.paypoint.resource;
|
||||
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
@@ -29,7 +28,6 @@ public class CustomerResource {
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response addCustomer(Customer customer) {
|
||||
customerService.addCustomer(customer);
|
||||
return Response.ok().build();
|
||||
return Response.ok(customerService.addCustomer(customer)).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,12 @@ public class AppointmentService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void add(Appointment appointment, Long companyId) {
|
||||
public Appointment add(Appointment appointment, Long companyId) {
|
||||
Company company = companyRepository.findById(companyId);
|
||||
appointment.setCompany(company);
|
||||
appointmentRepository.persist(appointment);
|
||||
emailService.stuurBevestiging(appointment);
|
||||
return appointment;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@@ -59,7 +60,7 @@ public class AppointmentService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void update(Appointment appointment) {
|
||||
public Appointment update(Appointment appointment) {
|
||||
Appointment appointmentToUpdate = appointmentRepository.findById(appointment.getId());
|
||||
appointmentToUpdate.setTitle(appointment.getTitle());
|
||||
appointmentToUpdate.setStartDate(appointment.getStartDate());
|
||||
@@ -72,6 +73,7 @@ public class AppointmentService {
|
||||
appointmentToUpdate.setDurationInMinutes(appointment.getDurationInMinutes());
|
||||
appointmentRepository.persist(appointmentToUpdate);
|
||||
emailService.stuurBewerking(appointmentToUpdate);
|
||||
return appointmentToUpdate;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@@ -28,7 +28,8 @@ public class CustomerService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void addCustomer(Customer customer) {
|
||||
public Customer addCustomer(Customer customer) {
|
||||
customerRepository.persist(customer);
|
||||
return customer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public class EmailService {
|
||||
String subject = String.format(" Afspraak geannuleerd: %s", formattedDate);
|
||||
String recipient = appointment.getCustomer().getEmail();
|
||||
|
||||
mailer.send(Mail.withHtml(recipient, subject, emailBody).setFrom("Hairstyling By Daan <paypoint@melvanveen.nl>"));
|
||||
mailer.send(Mail.withHtml(recipient, subject, emailBody).setFrom("Hairstyling By Daan <paypoint@melvanveen.nl>").setReplyTo(company.getEmail()));
|
||||
}
|
||||
|
||||
public void stuurBewerking(Appointment appointment) {
|
||||
@@ -285,7 +285,7 @@ public class EmailService {
|
||||
String subject = String.format(" Afspraak gewijzigd: %s", formattedDate);
|
||||
String recipient = appointment.getCustomer().getEmail();
|
||||
|
||||
mailer.send(Mail.withHtml(recipient, subject, emailBody).setFrom(company.getEmail()));
|
||||
mailer.send(Mail.withHtml(recipient, subject, emailBody).setFrom("Hairstyling By Daan <paypoint@melvanveen.nl>").setReplyTo(company.getEmail()));
|
||||
}
|
||||
|
||||
public void stuurHerinnering(Appointment appointment) {
|
||||
|
||||
@@ -13,6 +13,9 @@ quarkus.http.cors.origins=${CORS_ORIGINS}
|
||||
quarkus.http.cors.methods=GET,POST,OPTIONS,DELETE,PUT
|
||||
quarkus.http.root-path=/api
|
||||
|
||||
quarkus.smallrye-openapi.path=/openapi
|
||||
quarkus.swagger-ui.always-include=true
|
||||
|
||||
# Mailer configuratie
|
||||
quarkus.mailer.from=${MAILER_FROM}
|
||||
quarkus.mailer.host=${MAILER_HOST}
|
||||
@@ -45,6 +48,11 @@ smallrye.jwt.new-token.lifespan=3600
|
||||
#quarkus.log.category."io.quarkus.rest".level=DEBUG
|
||||
|
||||
|
||||
%test.quarkus.smallrye-openapi.path=/openapi
|
||||
%test.quarkus.swagger-ui.always-include=true
|
||||
|
||||
%prod.quarkus.swagger-ui.always-include=false
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user