Compare commits
4 Commits
0e2fb945a4
...
1b92fd269e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b92fd269e | ||
|
|
23025e3606 | ||
|
|
38c11e2d9f | ||
|
|
610723c561 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -82,3 +82,5 @@ testem.log
|
|||||||
# System files
|
# System files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
|
**/ci/bin/
|
||||||
@@ -41,6 +41,17 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ application:
|
|||||||
path: /home/florian/Developpement/codiki-hexagonal/backend/pictures-folder/
|
path: /home/florian/Developpement/codiki-hexagonal/backend/pictures-folder/
|
||||||
temp-path : /home/florian/Developpement/codiki-hexagonal/backend/pictures-folder/temp/
|
temp-path : /home/florian/Developpement/codiki-hexagonal/backend/pictures-folder/temp/
|
||||||
|
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
org.springframework.security: DEBUG
|
||||||
|
|
||||||
server:
|
server:
|
||||||
port: 8987
|
port: 8987
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
application:
|
||||||
|
pictures:
|
||||||
|
path: /opt/codiki/pictures/
|
||||||
|
temp-path: /opt/codiki/pictures/temp/
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: 8080
|
||||||
|
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:postgresql://codiki-database:5432/codiki_db
|
||||||
|
username: codiki_user
|
||||||
|
password: password
|
||||||
@@ -9,10 +9,6 @@ application:
|
|||||||
path: /opt/codiki/pictures/
|
path: /opt/codiki/pictures/
|
||||||
temp-path: /opt/codiki/pictures/temp/
|
temp-path: /opt/codiki/pictures/temp/
|
||||||
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
org.springframework.security: DEBUG
|
|
||||||
|
|
||||||
server:
|
server:
|
||||||
http2:
|
http2:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
95
ci.bash
Normal file
95
ci.bash
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SERVER_CODIKI_ROOT_FOLDER='/home/florian/codiki-hexagonal'
|
||||||
|
SERVER_ADDRESS='192.168.0.153'
|
||||||
|
SERVER_USER='florian'
|
||||||
|
SERVER_PORT='22'
|
||||||
|
|
||||||
|
function handle_error() {
|
||||||
|
local resultCode=$1
|
||||||
|
if [[ $resultCode -ne 0 ]]
|
||||||
|
then
|
||||||
|
echo "$errorMessage"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo 'Operation succeded.'
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function change_configuration_files() {
|
||||||
|
echo 'Copy production configuration file of backend...'
|
||||||
|
cp ./ci/configuration/backend/application-prod.yml ./backend/codiki-launcher/src/main/resources/application-prod.yml
|
||||||
|
handle_error $?
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_backend() {
|
||||||
|
echo 'Backend docker image building...'
|
||||||
|
docker build -t codiki-backend -f ./Dockerfile-backend . --no-cache
|
||||||
|
handle_error $?
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_frontend() {
|
||||||
|
echo 'Frontend docker image building...'
|
||||||
|
docker build -t codiki-frontend -f ./Dockerfile-frontend . --no-cache
|
||||||
|
handle_error $?
|
||||||
|
}
|
||||||
|
|
||||||
|
function extract_docker_images() {
|
||||||
|
echo 'Extraction of backend docker image into an archive...'
|
||||||
|
docker save codiki-backend:latest -o ./ci/bin/codiki-backend.tar
|
||||||
|
handle_error $?
|
||||||
|
|
||||||
|
echo 'Extraction of frontend docker image into an archive...'
|
||||||
|
docker save codiki-frontend:latest -o ./ci/bin/codiki-frontend.tar
|
||||||
|
handle_error $?
|
||||||
|
}
|
||||||
|
|
||||||
|
function copy_docker_compose_file_in_bin_folder() {
|
||||||
|
echo 'Copy of docker compose file in bin folder...'
|
||||||
|
cp ./docker-compose.yml ./ci/bin/docker-compose.yml
|
||||||
|
handle_error $?
|
||||||
|
}
|
||||||
|
|
||||||
|
function upload_files_on_server() {
|
||||||
|
echo 'Sending of docker images on server'
|
||||||
|
scp -P $SERVER_PORT ./ci/bin/* $SERVER_USER@$SERVER_ADDRESS:$SERVER_CODIKI_ROOT_FOLDER/
|
||||||
|
handle_error $?
|
||||||
|
}
|
||||||
|
|
||||||
|
# execute_remote_command_on_server
|
||||||
|
function ercos() {
|
||||||
|
local command=$1
|
||||||
|
ssh -p $SERVER_PORT -l $SERVER_USER $SERVER_ADDRESS $command
|
||||||
|
handle_error $1
|
||||||
|
}
|
||||||
|
|
||||||
|
function deploy_docker_images_on_server() {
|
||||||
|
echo 'Import backend docker image archive on server...'
|
||||||
|
ercos "docker load < $SERVER_CODIKI_ROOT_FOLDER/codiki-backend.tar"
|
||||||
|
|
||||||
|
echo 'Import frontend docker image archive on server...'
|
||||||
|
ercos "docker load < $SERVER_CODIKI_ROOT_FOLDER/codiki-frontend.tar"
|
||||||
|
}
|
||||||
|
|
||||||
|
function restart_services() {
|
||||||
|
echo 'Stop services on server...'
|
||||||
|
ercos "cd $SERVER_CODIKI_ROOT_FOLDER && docker compose down"
|
||||||
|
|
||||||
|
echo 'Start services on server...'
|
||||||
|
ercos "cd $SERVER_CODIKI_ROOT_FOLDER && docker compose up --detach"
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
change_configuration_files
|
||||||
|
build_backend
|
||||||
|
build_frontend
|
||||||
|
extract_docker_images
|
||||||
|
copy_docker_compose_file_in_bin_folder
|
||||||
|
upload_files_on_server
|
||||||
|
deploy_docker_images_on_server
|
||||||
|
restart_services
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
13
ci/configuration/backend/application-prod.yml
Normal file
13
ci/configuration/backend/application-prod.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
application:
|
||||||
|
pictures:
|
||||||
|
path: /opt/codiki/pictures/
|
||||||
|
temp-path: /opt/codiki/pictures/temp/
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: 8080
|
||||||
|
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:postgresql://codiki-database:5432/codiki_db
|
||||||
|
username: codiki_user
|
||||||
|
password: password
|
||||||
38
docker-compose.yml
Normal file
38
docker-compose.yml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
services:
|
||||||
|
codiki-database:
|
||||||
|
image: "postgres:16"
|
||||||
|
container_name: "codiki-database"
|
||||||
|
ports:
|
||||||
|
- "50010:5432"
|
||||||
|
networks:
|
||||||
|
- "codiki-network"
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: codiki_db
|
||||||
|
POSTGRES_USER: codiki_admin
|
||||||
|
POSTGRES_PASSWORD: password
|
||||||
|
PGDATA: /var/lib/postgresql/data/pgdata
|
||||||
|
volumes:
|
||||||
|
- "./docker/postgresql/pgdata:/var/lib/postgresql/data/pgdata"
|
||||||
|
|
||||||
|
codiki-backend:
|
||||||
|
image: codiki-backend:latest
|
||||||
|
container_name: "codiki-backend"
|
||||||
|
environment:
|
||||||
|
- "SPRING_PROFILES_ACTIVE=prod"
|
||||||
|
ports:
|
||||||
|
- "50011:8080"
|
||||||
|
volumes:
|
||||||
|
- "/opt/codiki/pictures:/opt/codiki/pictures"
|
||||||
|
networks:
|
||||||
|
- "codiki-network"
|
||||||
|
|
||||||
|
codiki-frontend:
|
||||||
|
image: codiki-frontend:latest
|
||||||
|
container_name: "codiki-frontend"
|
||||||
|
ports:
|
||||||
|
- "50012:80"
|
||||||
|
networks:
|
||||||
|
- "codiki-network"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
codiki-network:
|
||||||
@@ -9,6 +9,12 @@ http {
|
|||||||
~*^en en;
|
~*^en en;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
types {
|
||||||
|
module js;
|
||||||
|
}
|
||||||
|
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name codiki.org;
|
server_name codiki.org;
|
||||||
@@ -38,7 +44,7 @@ http {
|
|||||||
}
|
}
|
||||||
|
|
||||||
location ~ ^/api {
|
location ~ ^/api {
|
||||||
proxy_pass http://codiki-backend:8080;
|
proxy_pass http://192.168.0.153:50011;
|
||||||
proxy_set_header Host $host:$server_port;
|
proxy_set_header Host $host:$server_port;
|
||||||
proxy_set_header X-Forwarded-Host $server_name;
|
proxy_set_header X-Forwarded-Host $server_name;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
"start-en": "ng serve --port 4201 --configuration=en --proxy-config proxy.conf.json",
|
"start-en": "ng serve --port 4201 --configuration=en --proxy-config proxy.conf.json",
|
||||||
"start-fr": "ng serve --port 4201 --configuration=fr --proxy-config proxy.conf.json",
|
"start-fr": "ng serve --port 4201 --configuration=fr --proxy-config proxy.conf.json",
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"build-prod-en": "ng build --configuration=production-en --base-href",
|
"build-prod-en": "ng build --configuration=production-en --base-href /en/",
|
||||||
"build-prod-fr": "ng build --configuration=production-fr --base-href",
|
"build-prod-fr": "ng build --configuration=production-fr --base-href /fr/",
|
||||||
"watch": "ng build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"i18n": "ng extract-i18n --output-path src/locale --format=json"
|
"i18n": "ng extract-i18n --output-path src/locale --format=json"
|
||||||
|
|||||||
Reference in New Issue
Block a user