feat(niki): dockerize niki

This commit is contained in:
mohammad mahdi rezaei 2024-03-09 10:29:51 +03:30 committed by mehdi
parent 9fc2b59014
commit 659cba01d3
8 changed files with 134 additions and 19 deletions

View File

@ -17,7 +17,7 @@ WORKDIR /$APP_NAME
COPY . . COPY . .
# Budild application # Budild application
RUN CGO_ENABLED=0 go build -mod=vendor -v -o $APP_NAME . RUN CGO_ENABLED=0 go build -mod=mod -v -o $APP_NAME .
# Run Stage # Run Stage

View File

@ -9,7 +9,7 @@ http_server:
mysql: mysql:
port: 3306 port: 3306
host: niki-database host: niki-mariadb
db_name: niki_db db_name: niki_db
username: niki username: niki
password: nikiappt0lk2o20 password: nikiappt0lk2o20

View File

View File

@ -0,0 +1,19 @@
version: '3.7'
services:
niki_app_stage:
image: niki:${STAGE_NIKI_IMAGE_VERSION}
container_name: niki_app_stage
restart: always
ports:
- '127.0.0.1:8198:1313'
networks:
- niki-stage
volumes:
- './config.yml:/config.yml'
networks:
niki-stage:
external: true
# STAGE_NIKI_IMAGE_VERSION=770f31ea docker compose -p niki_app_stage up -d

36
deploy/stage/config.yml Normal file
View File

@ -0,0 +1,36 @@
---
type: yml
auth:
sign_key: jwt_secret_stage_nik
http_server:
port: 1313
mysql:
port: 3306
host: niki_stage_mariadb
db_name: niki_db
username: niki
password: n0ki2agd23
redis:
port: 6379
host: niki_stage_redis
password: ""
db: 0
sms_provider:
host: localhost
port: 443
benefactor_service:
length_of_otp_code: 5
kavenegar_sms_provider:
api_key: insert_your_api_key
otp_template_new_user: ebhomeverify
otp_template_registered_user: ebhomeverify
admin_auth:
sign_key: admin-jwt_secret_test_nik

View File

@ -0,0 +1,37 @@
version: '3.1'
services:
niki_stage_mariadb:
image: docker.io/bitnami/mariadb:11.1
container_name: niki_stage_mariadb
restart: always
ports:
- '127.0.0.1:3429:3306'
networks:
- niki-stage
volumes:
- 'niki_stage_mariadb_data:/bitnami/mariadb'
environment:
- MARIADB_USER=niki
- MARIADB_PASSWORD=${NIKI_STAGE_MARIADB_UR_PASSWORD}
- MARIADB_DATABASE=niki_db
- MARIADB_ROOT_PASSWORD=${NIKI_STAGE_MARIADB_RT_PASSWORD}
- ALLOW_EMPTY_PASSWORD=no
healthcheck:
test: ['CMD', '/opt/bitnami/scripts/mariadb/healthcheck.sh']
interval: 15s
timeout: 5s
retries: 6
deploy:
resources:
limits:
cpus: '1'
memory: 2048M
volumes:
niki_stage_mariadb_data:
driver: local
networks:
niki-stage:
external: true

View File

@ -0,0 +1,25 @@
version: '3.1'
services:
niki_stage_redis:
image: bitnami/redis:6.2
container_name: niki_stage_redis
restart: always
ports:
- '127.0.0.1:6380:6379'
# TODO - remove `--save "" --appendonly no` from command to persist data
command: redis-server --loglevel warning --protected-mode no --save "" --appendonly no
environment:
- ALLOW_EMPTY_PASSWORD=yes
networks:
- core
volumes:
- niki__stage_redis_data:/data
volumes:
niki__stage_redis_data:
driver: local
networks:
niki-stage:
external: true

View File

@ -13,29 +13,27 @@ services:
ports: ports:
- "1313:1313" - "1313:1313"
links: links:
- "niki-mysql" - "niki-mariadb"
depends_on: depends_on:
- "niki-mysql" - "niki-mariadb"
- "niki-redis" - "niki-redis"
niki-mariadb:
image: docker.io/bitnami/mariadb:11.1
niki-mysql: container_name: niki-mariadb
image: mysql:8.0 restart: always
ports: ports:
- "3306:3306" - '127.0.0.1:3306:3306'
container_name: niki-database
volumes:
- dbdata:/var/lib/mysql
networks: networks:
- core - core
restart: always volumes:
command: [ 'mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci' ] - 'niki-mariadb-data:/bitnami/mariadb'
environment: environment:
MYSQL_ROOT_PASSWORD: nikiRoo7t0lk2o20 MARIADB_USER: niki
MYSQL_DATABASE: niki_db MARIADB_PASSWORD: ${NIKI_STAGE_MARIADB_UR_PASSWORD}
MYSQL_USER: niki MARIADB_DATABASE: niki_db
MYSQL_PASSWORD: nikiappt0lk2o20 MARIADB_ROOT_PASSWORD: ${NIKI_STAGE_MARIADB_RT_PASSWORD}
ALLOW_EMPTY_PASSWORD: no
niki-redis: niki-redis:
image: bitnami/redis:6.2 image: bitnami/redis:6.2
@ -54,7 +52,7 @@ services:
volumes: volumes:
dbdata: niki-mariadb-data:
niki-redis-data: niki-redis-data:
networks: networks: