Skip to content

Commit

Permalink
fix(notes): fix dockerisation of notes service
Browse files Browse the repository at this point in the history
  • Loading branch information
ztdevelops committed Feb 22, 2024
1 parent dbe704c commit 2e69343
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 83 deletions.
162 changes: 81 additions & 81 deletions deployment/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
version: "3.8"

# secrets:
# kong_db_password:
# file: ./kong_db_password.txt
secrets:
kong_db_password:
file: ./kong_db_password.txt

# x-common-env:
# &common-env
# KONG_PG_HOST: kong-database
# KONG_PG_USER: kong
# KONG_PG_PASSWORD_FILE: /run/secrets/kong_db_password
x-common-env:
&common-env
KONG_PG_HOST: kong-database
KONG_PG_USER: kong
KONG_PG_PASSWORD_FILE: /run/secrets/kong_db_password

networks:
default:

volumes:
# kong-data: {}
# user-storage-db-volume: {}
kong-data: {}
user-storage-db-volume: {}
notes-db-volume: {}

services:
# kong-gateway:
# image: kong:latest
# build: ../../kong-gateway
# environment:
# <<: *common-env
# KONG_DATABASE: off
# KONG_PLUGINS: bundled,authn-kong
# KONG_DECLARATIVE_CONFIG: /etc/kong/kong.yml
# ports:
# - "8000:8000" # Proxy
# # - "8001:8001" # Admin API
# - "8443:8443" # Proxy SSL
# - "8444:8444" # Admin API SSL
# healthcheck:
# test: ["CMD", "kong", "health"]
# interval: 10s
# timeout: 5s
# retries: 5
# secrets:
# - kong_db_password
# restart: on-failure
# volumes:
# - ../../kong-gateway/kong.yml:/etc/kong/kong.yml
# - ../../kong-gateway/authn-kong:/usr/local/share/lua/5.1/kong/plugins/authn-kong
# - ../../kong-gateway/protos:/usr/local/share/lua/5.1/kong/protos
kong-gateway:
image: kong:latest
build: ../../kong-gateway
environment:
<<: *common-env
KONG_DATABASE: off
KONG_PLUGINS: bundled,authn-kong
KONG_DECLARATIVE_CONFIG: /etc/kong/kong.yml
ports:
- "8000:8000" # Proxy
# - "8001:8001" # Admin API
- "8443:8443" # Proxy SSL
- "8444:8444" # Admin API SSL
healthcheck:
test: ["CMD", "kong", "health"]
interval: 10s
timeout: 5s
retries: 5
secrets:
- kong_db_password
restart: on-failure
volumes:
- ../../kong-gateway/kong.yml:/etc/kong/kong.yml
- ../../kong-gateway/authn-kong:/usr/local/share/lua/5.1/kong/plugins/authn-kong
- ../../kong-gateway/protos:/usr/local/share/lua/5.1/kong/protos

# user-storage-db:
# image: postgres
# volumes:
# - user-storage-db-volume:/var/lib/postgresql/data
# - ../sql_table/create_user_storage_table.sql:/docker-entrypoint-initdb.d/user_storage.sql
# environment:
# POSTGRES_DB: user_storage_db
# POSTGRES_USER: user_storage_user
# POSTGRES_PASSWORD: user_storage_password
# ports:
# - "5432:5432"
# healthcheck:
# test: ["CMD-SHELL", "pg_isready -U user_storage_user -d user_storage_db"]
# interval: 10s
# timeout: 5s
# retries: 5
user-storage-db:
image: postgres
volumes:
- user-storage-db-volume:/var/lib/postgresql/data
- ../sql_table/create_user_storage_table.sql:/docker-entrypoint-initdb.d/user_storage.sql
environment:
POSTGRES_DB: user_storage_db
POSTGRES_USER: user_storage_user
POSTGRES_PASSWORD: user_storage_password
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U user_storage_user -d user_storage_db"]
interval: 10s
timeout: 5s
retries: 5

notes-db:
image: mysql:latest
Expand All @@ -71,48 +71,48 @@ services:
- "3306:3306"
volumes:
- notes-db-volume:/var/lib/mysql
- ../sql_table/create_notes_table.sql:/docker-entrypoint-initdb.d/create_notes_table.sql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"]
interval: 10s
timeout: 5s
retries: 5

# user-redis:
# image: redis:7.2-rc2-alpine3.18
# command: redis-server --requirepass password
# healthcheck:
# test: [ "CMD", "redis-cli", "-a", "password", "--raw", "incr", "ping" ]
# interval: 5s
# timeout: 5s
# retries: 5
user-redis:
image: redis:7.2-rc2-alpine3.18
command: redis-server --requirepass password
healthcheck:
test: [ "CMD", "redis-cli", "-a", "password", "--raw", "incr", "ping" ]
interval: 5s
timeout: 5s
retries: 5

notes-service:
build: ../../notes
depends_on:
# kong-gateway:
# condition: service_healthy
kong-gateway:
condition: service_healthy
notes-db:
condition: service_healthy
ports:
- "50052:50052"

- "50052:50052"

# user-storage-service:
# build: ../../user-storage
# image: user-storage-service:1.0
# depends_on:
# kong-gateway:
# condition: service_healthy
# user-storage-db:
# condition: service_healthy
# ports:
# - "50051:50051"
user-storage-service:
build: ../../user-storage
image: user-storage-service:1.0
depends_on:
kong-gateway:
condition: service_healthy
user-storage-db:
condition: service_healthy
ports:
- "50051:50051"

# frontend-client:
# build: ../../client
# image: client:1.0
# depends_on:
# kong-gateway:
# condition: service_healthy
# ports:
# - "3001:3001"
frontend-client:
build: ../../client
image: client:1.0
depends_on:
kong-gateway:
condition: service_healthy
ports:
- "3001:3001"
File renamed without changes.
2 changes: 1 addition & 1 deletion notes/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Use an official Python runtime as a parent image
FROM python:3.9-slim

ENV PYTHONUNBUFFERED=1
# Set the working directory in the container
WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion notes/note_upload_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
db_conn = mysql.connector.connect(
host=os.getenv('DB_HOST'),
user=os.getenv('DB_USER'),
password=os.getenv('DB_PASSWORD'),
password=os.getenv('DB_PASS'),
database="my_notes_app"
)
db_cursor = db_conn.cursor()
Expand Down

0 comments on commit 2e69343

Please sign in to comment.