Skip to content
Snippets Groups Projects
Commit 7e2c62dc authored by Rémi PAILHAREY's avatar Rémi PAILHAREY :fork_knife_plate:
Browse files

chore: better local config

parent d7477c5d
Branches
Tags
2 merge requests!89MEP,!87Resolve "TECH - Better local config"
...@@ -5,7 +5,7 @@ ADMIN_ROLE=ADMINS ...@@ -5,7 +5,7 @@ ADMIN_ROLE=ADMINS
DEBUG_MODE DEBUG_MODE
MOCK_OAUTH2 MOCK_OAUTH2
HTTPS_PORT HTTPS_PORT
IMAGE_FOLDER IMAGE_FOLDER=mnt/image-lib
# Needed to user OAuth2 authentication : # Needed to user OAuth2 authentication :
REDIRECT_URL REDIRECT_URL
......
.env .env
backoffice.db backoffice.db
db_data/ db_data/
\ No newline at end of file mnt/
__debug_bin*
# Swagger documentation
docs/swagger.json
docs/swagger.yaml
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Backoffice Server",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/main.go",
"envFile": "${workspaceFolder}/.env",
"showLog": true
}
]
}
...@@ -28,11 +28,6 @@ WORKDIR /app ...@@ -28,11 +28,6 @@ WORKDIR /app
ADD . . ADD . .
# Build Swagger documentation
RUN go install github.com/swaggo/swag/cmd/swag@latest
RUN go get github.com/swaggo/swag
RUN swag init -g ./internal/rootmux/rootmux.go
# Get dependencies and run tests # Get dependencies and run tests
RUN go version RUN go version
RUN go get -d -v RUN go get -d -v
...@@ -43,6 +38,8 @@ RUN CGO_ENABLED=0 go build \ ...@@ -43,6 +38,8 @@ RUN CGO_ENABLED=0 go build \
-ldflags='-w -s -extldflags "-static"' -a \ -ldflags='-w -s -extldflags "-static"' -a \
-o /app/backoffice-server . -o /app/backoffice-server .
RUN mkdir -p /app/mnt /app/mnt/configs
RUN chown -Rf "${UID}" ./* RUN chown -Rf "${UID}" ./*
# Allow running on ports < 1000 # Allow running on ports < 1000
...@@ -67,9 +64,6 @@ COPY --from=builder /app/backoffice-server /app/backoffice-server ...@@ -67,9 +64,6 @@ COPY --from=builder /app/backoffice-server /app/backoffice-server
COPY --from=builder /app/dev_certificates /app/dev_certificates COPY --from=builder /app/dev_certificates /app/dev_certificates
COPY --from=builder /app/mnt/configs /app/mnt/configs COPY --from=builder /app/mnt/configs /app/mnt/configs
# Copy swagger documentation folder
COPY --from=builder /app/docs /app/docs
# Use an unprivileged user. # Use an unprivileged user.
USER appuser:appuser USER appuser:appuser
......
version: '3.1' version: "3.1"
services: services:
database: database:
image: mysql:8 image: mysql:8
healthcheck: healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD
interval: 5s interval: 5s
timeout: 10s timeout: 10s
retries: 60 retries: 60
volumes: volumes:
- ./db_data:/var/lib/mysql - ./db_data:/var/lib/mysql
networks: networks:
- ecolyo-agent-network - ecolyo-agent-network
ports: ports:
- 3306:3306 - 3306:3306
environment: environment:
MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD} MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD}
MYSQL_DATABASE: ${DATABASE_NAME} MYSQL_DATABASE: ${DATABASE_NAME}
phpmyadmin: phpmyadmin:
image: phpmyadmin/phpmyadmin:latest image: phpmyadmin/phpmyadmin:latest
depends_on: depends_on:
- database - database
networks: networks:
- ecolyo-agent-network - ecolyo-agent-network
ports: ports:
- 8008:80 - 8008:80
environment: environment:
PMA_HOST: database PMA_HOST: database
volumes: volumes:
db_data: db_data:
networks: networks:
ecolyo-agent-network: ecolyo-agent-network:
\ No newline at end of file
{
"Key": "2ioa6+gmlILIQcsG/HmBqDSsszPCe4GWKjCfyrtgLek="
}
\ No newline at end of file
#!/bin/bash
# See https://stackoverflow.com/questions/24112727/relative-paths-based-on-file-location-instead-of-current-working-directory
WD=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$WD"
# Get env variables
source ../.env
REGISTRY_ID=409
EMAIL_ASSETS_PATH="src/assets/icons/email"
ECOGESTURE_ASSETS_PATH="src/assets/icons/visu/ecogesture"
# Clear folder
rm -rf ../$IMAGE_FOLDER
# Create folder
mkdir -p ../$IMAGE_FOLDER ../$IMAGE_FOLDER/ecogesture
# Fetch and convert email assets
curl "https://forge.grandlyon.com/api/v4/projects/${REGISTRY_ID}/repository/archive?path=${EMAIL_ASSETS_PATH}" --output email.tar.gz
tar -xf email.tar.gz
find *-email/$EMAIL_ASSETS_PATH -type f -name "*.svg" | while read -r svg_file; do
filename="$(basename "$svg_file" .svg)"
inkscape -h 200 -o ../$IMAGE_FOLDER/$filename.png *-email/$EMAIL_ASSETS_PATH/$filename.svg
done
rm *-email/$EMAIL_ASSETS_PATH/*.svg
# Fetch and convert ecogesture assets
curl "https://forge.grandlyon.com/api/v4/projects/${REGISTRY_ID}/repository/archive?path=${ECOGESTURE_ASSETS_PATH}" --output ecogesture.tar.gz
tar -xf ecogesture.tar.gz
find *-ecogesture/$ECOGESTURE_ASSETS_PATH -type f -name "*.svg" | while read -r svg_file; do
filename="$(basename "$svg_file" .svg)"
inkscape -h 200 -o ../$IMAGE_FOLDER/ecogesture/$filename.png *-ecogesture/$ECOGESTURE_ASSETS_PATH/$filename.svg
done
rm *-ecogesture/$ECOGESTURE_ASSETS_PATH/*.svg
# Cleanup
rm -rf email.tar.gz ecogesture.tar.gz *-email *-ecogesture
#!/bin/bash
# See https://stackoverflow.com/questions/24112727/relative-paths-based-on-file-location-instead-of-current-working-directory
WD=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$WD/.."
source .env
# REMOVE PRICES TABLE
docker compose exec database mysql -u${DATABASE_USER} -p${DATABASE_PASSWORD} -e "use $DATABASE_NAME; DROP TABLE prices;"
echo "Prices database dropped"
# CREATE PRICES TABLE
docker compose exec database mysql -u${DATABASE_USER} -p${DATABASE_PASSWORD} -e "use $DATABASE_NAME; CREATE TABLE prices (
id int(11) NOT NULL,
fluid_type bigint(20) DEFAULT NULL,
price float DEFAULT NULL,
start_date longtext,
end_date longtext,
created_at datetime(3) DEFAULT NULL,
updated_at datetime(3) DEFAULT NULL,
deleted_at datetime(3) DEFAULT NULL
);"
echo "Prices database created"
# POPULATE PRICES TABLE
docker compose exec database mysql -u${DATABASE_USER} -p${DATABASE_PASSWORD} -e "use $DATABASE_NAME; INSERT INTO prices (id, fluid_type, price, start_date, end_date) VALUES
(1,0,0.1256,'2012-07-23 00:00:00','2013-07-31 23:59:59'),
(2,0,0.1329,'2013-08-01 00:00:00','2014-10-31 23:59:59'),
(3,0,0.1401,'2014-01-11 00:00:00','2015-07-31 23:59:59'),
(4,0,0.1437,'2015-08-01 00:00:00','2016-07-31 23:59:59'),
(5,0,0.1503,'2016-08-01 00:00:00','2017-07-31 23:59:59'),
(6,0,0.1546,'2017-08-01 00:00:00','2018-01-31 23:59:59'),
(7,0,0.1555,'2018-02-01 00:00:00','2018-07-31 23:59:59'),
(8,0,0.145,'2018-08-01 00:00:00','2019-05-31 23:59:59'),
(9,0,0.1531,'2019-02-01 00:00:00','2019-07-31 23:59:59'),
(10,0,0.1524,'2019-08-01 00:00:00','2020-01-31 23:59:59'),
(11,0,0.1546,'2020-02-01 00:00:00','2020-07-31 23:59:59'),
(12,0,0.1557,'2020-08-01 00:00:00','2021-01-31 23:59:59'),
(13,0,0.1582,'2021-02-01 00:00:00','2021-07-31 23:59:59'),
(14,0,0.1558,'2021-08-01 00:00:00','2022-01-31 23:59:59'),
(15,0,0.174,'2022-02-01 00:00:00',NULL),
(16,1,0.0030735,'2012-01-01 00:00:00','2012-12-31 23:59:59'),
(17,1,0.0031483,'2013-01-01 00:00:00','2013-12-31 23:59:59'),
(18,1,0.0031381,'2014-01-01 00:00:00','2014-12-31 23:59:59'),
(19,1,0.00307,'2015-01-01 00:00:00','2015-12-31 23:59:59'),
(20,1,0.0031,'2016-01-01 00:00:00','2016-12-31 23:59:59'),
(21,1,0.00311,'2017-01-01 00:00:00','2017-12-31 23:59:59'),
(22,1,0.00313,'2018-01-01 00:00:00','2018-12-31 23:59:59'),
(23,1,0.00313,'2019-01-01 00:00:00','2019-12-31 23:59:59'),
(24,1,0.00315,'2020-01-01 00:00:00','2020-12-31 23:59:59'),
(25,1,0.00319,'2021-01-01 00:00:00',NULL),
(26,2,0.0919,'2017-01-01 00:00:00','2017-01-31 23:59:59'),
(27,2,0.0915,'2017-02-01 00:00:00','2017-02-28 23:59:59'),
(28,2,0.0932,'2017-03-01 00:00:00','2017-03-31 23:59:59'),
(29,2,0.0927,'2017-04-01 00:00:00','2017-04-30 23:59:59'),
(30,2,0.0906,'2017-05-01 00:00:00','2017-05-31 23:59:59'),
(31,2,0.0906,'2017-06-01 00:00:00','2017-06-30 23:59:59'),
(32,2,0.0788,'2017-07-01 00:00:00','2017-07-31 23:59:59'),
(33,2,0.0783,'2017-08-01 00:00:00','2017-08-31 23:59:59'),
(34,2,0.0783,'2017-09-01 00:00:00','2017-09-30 23:59:59'),
(35,2,0.0791,'2017-10-01 00:00:00','2017-10-31 23:59:59'),
(36,2,0.0806,'2017-11-01 00:00:00','2017-11-30 23:59:59'),
(37,2,0.0812,'2017-12-01 00:00:00','2017-12-31 23:59:59'),
(38,2,0.0857,'2018-01-01 00:00:00','2018-01-31 23:59:59'),
(39,2,0.0866,'2018-02-01 00:00:00','2018-02-28 23:59:59'),
(40,2,0.0847,'2018-03-01 00:00:00','2018-03-31 23:59:59'),
(41,2,0.0839,'2018-04-01 00:00:00','2018-04-30 23:59:59'),
(42,2,0.0842,'2018-05-01 00:00:00','2018-05-31 23:59:59'),
(43,2,0.0855,'2018-06-01 00:00:00','2018-06-30 23:59:59'),
(44,2,0.0959,'2018-07-01 00:00:00','2018-07-31 23:59:59'),
(45,2,0.0961,'2018-08-01 00:00:00','2018-08-31 23:59:59'),
(46,2,0.0967,'2018-09-01 00:00:00','2018-09-30 23:59:59'),
(47,2,0.0989,'2018-10-01 00:00:00','2018-10-31 23:59:59'),
(48,2,0.1031,'2018-11-01 00:00:00','2018-11-30 23:59:59'),
(49,2,0.1013,'2018-12-01 00:00:00','2018-12-31 23:59:59'),
(50,2,0.0999,'2019-01-01 00:00:00','2019-01-31 23:59:59'),
(51,2,0.0993,'2019-02-01 00:00:00','2019-02-28 23:59:59'),
(52,2,0.0993,'2019-03-01 00:00:00','2019-03-31 23:59:59'),
(53,2,0.0977,'2019-04-01 00:00:00','2019-04-30 23:59:59'),
(54,2,0.0973,'2019-05-01 00:00:00','2019-05-31 23:59:59'),
(55,2,0.0969,'2019-06-01 00:00:00','2019-06-30 23:59:59'),
(56,2,0.0795,'2019-07-01 00:00:00','2019-07-31 23:59:59'),
(57,2,0.0791,'2019-08-01 00:00:00','2019-08-31 23:59:59'),
(58,2,0.0785,'2019-09-01 00:00:00','2019-09-30 23:59:59'),
(59,2,0.077,'2019-10-01 00:00:00','2019-10-31 23:59:59'),
(60,2,0.0789,'2019-11-01 00:00:00','2019-11-30 23:59:59'),
(61,2,0.0793,'2019-12-01 00:00:00','2019-12-31 23:59:59'),
(62,2,0.0787,'2020-01-01 00:00:00','2020-01-31 23:59:59'),
(63,2,0.0765,'2020-02-01 00:00:00','2020-02-29 23:59:59'),
(64,2,0.0736,'2020-03-01 00:00:00','2020-03-31 23:59:59'),
(65,2,0.071,'2020-04-01 00:00:00','2020-04-30 23:59:59'),
(66,2,0.0703,'2020-05-01 00:00:00','2020-05-31 23:59:59'),
(67,2,0.0687,'2020-06-01 00:00:00','2020-06-30 23:59:59'),
(68,2,0.0698,'2020-07-01 00:00:00','2020-07-31 23:59:59'),
(69,2,0.0705,'2020-08-01 00:00:00','2020-08-31 23:59:59'),
(70,2,0.0709,'2020-09-01 00:00:00','2020-09-30 23:59:59'),
(71,2,0.0735,'2020-10-01 00:00:00','2020-10-31 23:59:59'),
(72,2,0.0745,'2020-11-01 00:00:00','2020-11-30 23:59:59'),
(73,2,0.0759,'2020-12-01 00:00:00','2020-12-31 23:59:59'),
(74,2,0.076,'2021-01-01 00:00:00','2021-01-31 23:59:59'),
(75,2,0.0782,'2021-02-01 00:00:00','2021-02-28 23:59:59'),
(76,2,0.0818,'2021-03-01 00:00:00','2021-03-31 23:59:59'),
(77,2,0.079,'2021-04-01 00:00:00','2021-04-30 23:59:59'),
(78,2,0.0797,'2021-05-01 00:00:00','2021-05-31 23:59:59'),
(79,2,0.0826,'2021-06-01 00:00:00','2021-06-30 23:59:59'),
(80,2,0.0895,'2021-07-01 00:00:00','2021-07-31 23:59:59'),
(81,2,0.0934,'2021-08-01 00:00:00','2021-08-31 23:59:59'),
(82,2,0.1002,'2021-09-01 00:00:00','2021-09-30 23:59:59'),
(83,2,0.1121,'2021-10-01 00:00:00',NULL)
;"
echo "Prices database populated"
#!/bin/bash
# See https://stackoverflow.com/questions/24112727/relative-paths-based-on-file-location-instead-of-current-working-directory
WD=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$WD/.."
source .env
# Build documentation
swag init -g ./internal/rootmux/rootmux.go
# Keep only swagger.json and swagger.yaml
rm ./docs/docs.go
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment