Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 0.0
os: linux

files:
- source: /
destination: /home/ec2-user/server
permissions:
- object: /
pattern: "**"
owner: ec2-user
group: ec2-user
hooks:
BeforeInstall:
- location: scripts/server_clear.sh
timeout: 300
runas: ec2-user
AfterInstall:
- location: scripts/fix_privileges.sh
timeout: 300
runas: ec2-user
ApplicationStart:
- location: scripts/server_start.sh
timeout: 300
runas: ec2-user
ApplicationStop:
- location: scripts/server_stop.sh
timeout: 300
runas: ec2-user
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'com.h2database:h2'
runtimeOnly 'com.h2database:h2'
}

tasks.named('test') {
Expand Down
35 changes: 35 additions & 0 deletions buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: 0.2

env:
variables:
PROFILE: "default"
DATASOURCE_URL: "pedra"
DATASOURCE_USERNAME: "papel"
DATASOURCE_PASSWORD: "tesoura"
LOGISTOCK_URL: "lagarto"

phases:
install:
runtime-versions:
java: corretto17
commands:
- chmod +w src/main/resources/application.yml
- sed -i "s|spring.profiles.active = .*|spring.profiles.active = ${PROFILE}|g" src/main/resources/application.yml
- sed -i "s|spring.datasource.url = .*|spring.datasource.url = ${DATASOURCE_URL}|g" src/main/resources/application.yml
- sed -i "s|spring.datasource.username = .*|spring.datasource.username = ${DATASOURCE_USERNAME}|g" src/main/resources/application.yml
- sed -i "s|spring.datasource.password = .*|spring.datasource.password = ${DATASOURCE_PASSWORD}|g" src/main/resources/application.yml
- sed -i "s|client.logistock.url = .*|client.logistock.url = ${LOGISTOCK_URL}|g" src/main/resources/application.yml
- cat src/main/resources/application.yml

- chmod +x gradlew
build:
commands:
- ./gradlew bootJar
post_build:
commands:
- echo Build Completed
artifacts:
files:
- build/libs/*.jar
- scripts/*.sh
- appspec.yml
4 changes: 4 additions & 0 deletions scripts/fix_privileges.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
chmod +x /home/ec2-user/server/build/libs/*.jar
chmod +x /home/ec2-user/server/scripts/server_start.sh
chmod +x /home/ec2-user/server/scripts/server_stop.sh
3 changes: 3 additions & 0 deletions scripts/server_clear.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

find /home/ec2-user/server -mindepth 1 -delete
3 changes: 3 additions & 0 deletions scripts/server_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
cd /home/ec2-user/server/build/libs
sudo java -jar -Dserver.port=80 *.jar > /dev/null 2> /dev/null < /dev/null &
2 changes: 2 additions & 0 deletions scripts/server_stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
sudo pkill -f 'java -jar'
1 change: 1 addition & 0 deletions src/main/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ spring:
application:
name: InvoiceAPI
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:testdb
output:
ansi:
Expand Down
9 changes: 0 additions & 9 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,12 @@ spring:
url: jdbc:postgresql://localhost:5432/products
username: postgres_user_product
password: super_password
flyway:
enabled: true
url: jdbc:postgresql://localhost:5432/products
user: postgres_user_product
password: super_password
baselineOnMigrate: true
output:
ansi:
enabled: ALWAYS
jpa:
open-in-view: true

server:
port: 8081

client:
logistock:
url: http://localhost:8080