-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from JewelleryManagement/feature-ci-cd
Feature 88/ Add env specific configurations. Add AWS deployment files and workflow
- Loading branch information
Showing
18 changed files
with
175 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
FROM amazoncorretto:17-alpine-jdk | ||
COPY ./app.jar . | ||
ENTRYPOINT ["java", "-jar", "app.jar"] | ||
ENV SPRING_PROFILE=local | ||
ENTRYPOINT java -jar -Dspring.profiles.active=$SPRING_PROFILE app.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,40 @@ | ||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: Build and copy to S3 | ||
|
||
on: | ||
push: | ||
branches: [ "release*" ] | ||
|
||
env: | ||
AWS_REGION : eu-central-1 | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
name: Checkout repository | ||
|
||
- uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
role-to-assume: ${{ secrets.IAMROLE_GITHUB }} | ||
role-session-name: GithubAction | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Push jar and docker files to AWS S3 | ||
run: | | ||
zip -r backend_codedeploy.zip aws | ||
aws s3 cp backend_codedeploy.zip s3://${{ secrets.S3BUCKET }}/ |
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
name: build | ||
on: | ||
push: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
|
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 |
---|---|---|
|
@@ -36,6 +36,7 @@ build/ | |
.gradle/ | ||
|
||
# Spring Boot properties | ||
aws/docker/.env | ||
.env | ||
/src/main/resources/data.sql | ||
|
||
|
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,18 @@ | ||
version: 0.0 | ||
os: linux | ||
files: | ||
- source: /docker/ | ||
destination: /tmp/be | ||
hooks: | ||
BeforeInstall: | ||
- location: scripts/install_docker.sh | ||
timeout: 180 | ||
runas: root | ||
ApplicationStart: | ||
- location: scripts/start_docker.sh | ||
timeout: 180 | ||
runas: root | ||
ValidateService: | ||
- location: scripts/check_health.sh | ||
timeout: 180 | ||
runas: root |
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,8 @@ | ||
FROM postgres:13 | ||
ARG POSTGRES_DB | ||
ARG POSTGRES_USER | ||
ARG POSTGRES_PASSWORD | ||
|
||
ENV POSTGRES_DB=${POSTGRES_DB} | ||
ENV POSTGRES_USER=${POSTGRES_USER} | ||
ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD} |
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,50 @@ | ||
version: '3.8' | ||
name: jms-docker-be | ||
services: | ||
jms-be: | ||
image: vladokat/jms-be:893b8dc | ||
# build: | ||
# context: . | ||
# dockerfile: Dockerfile_app | ||
container_name: jms-be | ||
depends_on: | ||
- db | ||
environment: | ||
SPRING_PROFILE: cloud | ||
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/${JMS_DATABASE_NAME}?autoreconnect=true&createDatabaseIfNotExist=true&characterEncoding=utf8 | ||
JMS_DATABASE_NAME: ${JMS_DATABASE_NAME} | ||
JMS_DATABASE_USER: ${JMS_DATABASE_USER} | ||
JMS_DATABASE_PASSWORD: ${JMS_DATABASE_PASSWORD} | ||
SECRET_KEY: ${SECRET_KEY} | ||
ports: | ||
- "8080:8080" | ||
# volumes: | ||
# - ./jewellery-inventory-0.0.1-SNAPSHOT.jar:/jar/app.jar | ||
networks: | ||
- jms-network | ||
db: | ||
# container_name: postgres | ||
image: jms-db | ||
build: | ||
context: . | ||
dockerfile: Dockerfile_DB | ||
restart: always | ||
environment: | ||
POSTGRES_DB: ${JMS_DATABASE_NAME} | ||
POSTGRES_USER: ${JMS_DATABASE_USER} | ||
POSTGRES_PASSWORD: ${JMS_DATABASE_PASSWORD} | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
ports: | ||
- "5432:5432" | ||
networks: | ||
- jms-network | ||
|
||
volumes: | ||
postgres_data: | ||
|
||
networks: | ||
jms-network: | ||
name: jms-network | ||
driver: bridge | ||
|
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 @@ | ||
#!/bin/bash | ||
|
||
# Wait for the application to start (you may need to adjust this based on your app startup time) | ||
sleep 20 | ||
|
||
# Perform the health check | ||
if curl -s -o /dev/null -w "%{http_code}" http://3.123.158.214:8080/health | grep -q "200"; then | ||
echo "Application is healthy." | ||
exit 0 # Success | ||
else | ||
echo "Application health check failed." | ||
exit 1 # Failure | ||
fi |
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,5 @@ | ||
#!/bin/bash | ||
|
||
yum install -y docker #> /logs/install.log | ||
curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose | ||
chmod +x /usr/local/bin/docker-compose |
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,16 @@ | ||
#!/bin/bash | ||
|
||
# Set the environment variables for your application | ||
JMS_DATABASE_NAME=$(aws ssm get-parameter --name JMS_DATABASE_NAME --query "Parameter.Value" --with-decryption --output text) | ||
JMS_DATABASE_USER=$(aws ssm get-parameter --name JMS_DATABASE_USER --query "Parameter.Value" --with-decryption --output text) | ||
JMS_DATABASE_PASSWORD=$(aws ssm get-parameter --name JMS_DATABASE_PASSWORD --query "Parameter.Value" --with-decryption --output text) | ||
SECRET_KEY=$(aws ssm get-parameter --name SECRET_KEY --query "Parameter.Value" --with-decryption --output text) | ||
|
||
export JMS_DATABASE_NAME="$JMS_DATABASE_NAME" | ||
export JMS_DATABASE_USER="$JMS_DATABASE_USER" | ||
export JMS_DATABASE_PASSWORD="$JMS_DATABASE_PASSWORD" | ||
export SECRET_KEY="$SECRET_KEY" | ||
|
||
service docker start | ||
docker-compose build --no-cache --file /tmp/be/docker-compose.yml | ||
docker-compose --file /tmp/be/docker-compose.yml up -d --build |
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
14 changes: 6 additions & 8 deletions
14
src/main/java/jewellery/inventory/config/FlywayMigrationConfig.java
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,3 @@ | ||
cors.allowedOrigins=* | ||
spring.datasource.url=jdbc:postgresql://db:5432/${JMS_DATABASE_NAME}?autoreconnect=true&createDatabaseIfNotExist=true&characterEncoding=utf8 | ||
flyway.migration.location=classpath:db/migration/prod |
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
16 changes: 1 addition & 15 deletions
16
src/test/resources/application.properties → ...est/resources/application-test.properties
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 |
---|---|---|
@@ -1,27 +1,13 @@ | ||
# Specify the DB platform for Hibernate | ||
spring.datasource.url=jdbc:tc:postgresql:13:/// | ||
spring.jpa.hibernate.ddl-auto=none | ||
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect | ||
spring.datasource.driver-class-name=org.testcontainers.jdbc.ContainerDatabaseDriver | ||
|
||
# Show all queries Hibernate executes in console | ||
spring.jpa.show-sql=true | ||
cors.allowedOrigins=http://localhost:3000 | ||
cors.allowedMethods=GET,POST,PUT,DELETE | ||
cors.allowedHeaders=Authorization,Cache-Control,Content-Type | ||
|
||
jwt.secret.key=QdzigVY4XWNItestqpRdNuCGXx+FXok5e++GeMm1OlE= | ||
jwt.token.expiration=#{1000 * 60 * 24} | ||
|
||
spring.flyway.enabled=false | ||
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false | ||
|
||
## File Storage Properties | ||
# All files uploaded through the API will be stored in this directory | ||
image.folder.path=/tmp/Jms-test/Images/ | ||
|
||
# Max file size | ||
spring.servlet.multipart.max-file-size=12MB | ||
# Max Request Size | ||
spring.servlet.multipart.max-request-size=12MB | ||
multipart.file.max.size=8 | ||
image.folder.path=/tmp/Jms-test/Images/ |