Skip to content

Commit

Permalink
Name docker project as md-ship
Browse files Browse the repository at this point in the history
  • Loading branch information
tnsoftbear committed Nov 30, 2024
1 parent c39e507 commit fb2527b
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 139 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ init: ## Initialize environement variables
fi;
build: ## Build docker containers
docker compose $(cf) build
up: init ## Start docker containers
up: init ## Start docker containers
docker compose $(cf) up -d --remove-orphans
down: ## Stop docker containers
docker compose $(cf) down
Expand All @@ -27,7 +27,7 @@ restart: ## Restart docker containers

apitestbuild: ## Build containers for API testing
docker compose $(af) build
apitestup: ## Start containers for API testing
apitestup: ## Start containers for API testing
docker compose $(af) up -d --remove-orphans
apitestdown: ## Stop containers for API testing
docker compose $(af) down
Expand Down
14 changes: 7 additions & 7 deletions config/core.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
app:
listen_addr: 0.0.0.0:8080
redis_storage:
host: localhost
port: 6379
parcel_locker_service:
endpoint_url: http://localhost:8081
app:
listen_addr: 0.0.0.0:8080
redis_storage:
host: localhost
port: 6379
parcel_locker_service:
endpoint_url: http://localhost:8081
cache_ttl: 60
8 changes: 4 additions & 4 deletions deploy/docker/.env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APP_LISTEN_ADDR=0.0.0.0:8080
PARCEL_LOCKER_CACHE_TTL=60
PARCEL_LOCKER_SERVICE_ENDPOINT_URL=http://pl-app:8081
REDIS_HOST=ship-redis-storage
APP_LISTEN_ADDR=0.0.0.0:8080
PARCEL_LOCKER_CACHE_TTL=60
PARCEL_LOCKER_SERVICE_ENDPOINT_URL=http://md-pl-app:8081
REDIS_HOST=md-ship-redis-storage
REDIS_PORT=6379
20 changes: 10 additions & 10 deletions deploy/docker/compose-api-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ include:
- compose-base.yaml

services:
ship-app:
app:
extends:
file: compose.yaml
service: ship-app
service: app
depends_on:
- ship-redis-storage
- redis-storage

ship-redis-storage:
redis-storage:
extends:
file: compose.yaml
service: ship-redis-storage
service: redis-storage
volumes:
- ship-redis-api-test-data:/data
- redis-api-test-data:/data
- ./redis-storage/redis.conf:/usr/local/etc/redis/redis.conf

ship-redis-populator:
redis-populator:
extends:
file: compose.yaml
service: ship-redis-populator
service: redis-populator
entrypoint: ["sh", "/redis-populator/populate.sh", "/redis-populator/api-test-data.txt"]
depends_on:
- ship-redis-storage
- redis-storage

volumes:
ship-redis-api-test-data:
redis-api-test-data:
labels:
- "app-identity=delivery-magic"
- "app-volume=ship-redis-api-test-data"
28 changes: 14 additions & 14 deletions deploy/docker/compose-base.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
networks:
ship-public:
labels:
- "app-identity=delivery-magic"
- "app-network=ship-public"
name: md-ship-public
ship-redis:
labels:
- "app-identity=delivery-magic"
- "app-network=ship-redis"
name: md-ship-redis
pl-public:
name: md-pl-public
external: true
networks:
public:
labels:
- "app-identity=delivery-magic"
- "app-network=ship-public"
name: md-ship-public
redis:
labels:
- "app-identity=delivery-magic"
- "app-network=ship-redis"
name: md-ship-redis
md-pl-public:
name: md-pl-public
external: true
38 changes: 19 additions & 19 deletions deploy/docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
include:
- compose-base.yaml

name: md
name: md-ship

services:
ship-app:
app:
annotations:
com.chillysoftware.md.ship.app.lang: go
build:
context: ../..
dockerfile: ./deploy/docker/app/Dockerfile
container_name: md-ship-app
depends_on:
ship-redis-storage:
redis-storage:
condition: service_healthy
env_file:
- path: ./.env
- path: "./.env"
required: true
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/ping"]
Expand All @@ -27,15 +27,15 @@ services:
- "app-identity=magic-delivery"
- "app-service=md-ship-app"
networks:
- ship-public
- ship-redis
- pl-public
- public
- redis
- md-pl-public
ports:
- "8080:8080/tcp"
read_only: true
restart: unless-stopped

ship-redis-storage:
redis-storage:
container_name: md-ship-redis-storage
entrypoint: ["redis-server", "/usr/local/etc/redis/redis.conf"]
healthcheck:
Expand All @@ -49,16 +49,16 @@ services:
- "app-identity=magic-delivery"
- "app-service=md-ship-redis-storage"
networks:
- ship-redis
- redis
restart: unless-stopped
volumes:
- ship-redis-data:/data
- redis-data:/data
- ./redis-storage/redis.conf:/usr/local/etc/redis/redis.conf

ship-redis-populator:
redis-populator:
container_name: md-ship-redis-populator
depends_on:
- ship-redis-storage
- redis-storage
entrypoint: ["bash", "/redis-populator/populate.sh", "/redis-populator/data.txt"]
env_file:
- ./.env
Expand All @@ -67,15 +67,15 @@ services:
- "app-identity=magic-delivery"
- "app-service=md-ship-redis-populator"
networks:
- ship-redis
- redis
volumes:
- ./redis-populator:/redis-populator
read_only: true

ship-redis-backup:
redis-backup:
container_name: md-ship-redis-backup
depends_on:
- ship-redis-storage
- redis-storage
entrypoint: ["/snapshot-backup.sh"]
environment:
- BACKUP_PERIOD=10
Expand All @@ -84,16 +84,16 @@ services:
restart: unless-stopped
volumes:
- ./redis-backup/snapshot-backup.sh:/snapshot-backup.sh
- ship-redis-data:/data:ro
- ship-backup:/backup
- redis-data:/data:ro
- backup:/backup

volumes:
ship-backup:
backup:
name: md-ship-backup
labels:
- "app-identity=magic-delivery"
- "app-volume=md-ship-backup"
ship-redis-data:
redis-data:
name: md-ship-redis-data
labels:
- "app-identity=magic-delivery"
Expand Down
8 changes: 4 additions & 4 deletions deploy/docker/redis-populator/data.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
HSET customer_shipping_address:sample-shipping-address-id-1 Id "sample-shipping-address-id-1" City "Riga" Street "Nicgales 5" Longitude "56.959520" Latitude "24.174040"
HSET customer:sample-customer-id-1 Id "sample-customer-id-1" Name "Sample customer 1 name" Description "Sample customer 1 description" CreatedAt 2000001 AddressId "sample-shipping-address-id-1"
HSET customer:sample-customer-id-2 Id "sample-customer-id-2" Name "Sample customer 2 name" Description "Sample customer 2 description" CreatedAt 2000002
ZADD customers 2000001 "sample-customer-id-1"
HSET customer_shipping_address:sample-shipping-address-id-1 Id "sample-shipping-address-id-1" City "Riga" Street "Nicgales 5" Longitude "56.959520" Latitude "24.174040"
HSET customer:sample-customer-id-1 Id "sample-customer-id-1" Name "Sample customer 1 name" Description "Sample customer 1 description" CreatedAt 2000001 AddressId "sample-shipping-address-id-1"
HSET customer:sample-customer-id-2 Id "sample-customer-id-2" Name "Sample customer 2 name" Description "Sample customer 2 description" CreatedAt 2000002
ZADD customers 2000001 "sample-customer-id-1"
ZADD customers 2000002 "sample-customer-id-2"
2 changes: 1 addition & 1 deletion deploy/docker/redis-storage/redis.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dbfilename taskmanager.rdb
dbfilename taskmanager.rdb
save 60 1
4 changes: 2 additions & 2 deletions internal/app/action/deleting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestDeleteCustomer_NotFound(t *testing.T) {
w := httptest.NewRecorder()

r.DELETE("/customer/:id", func(c *gin.Context) {
DeleteCustomer(c, customerDeleterMock, customerLoaderMock)
DeleteCustomer(customerDeleterMock, customerLoaderMock)(c)
})
// Act
r.ServeHTTP(w, req)
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestDeleteCustomer_Found(t *testing.T) {
w := httptest.NewRecorder()

r.DELETE("/customer/:id", func(c *gin.Context) {
DeleteCustomer(c, customerDeleterMock, customerLoaderMock)
DeleteCustomer(customerDeleterMock, customerLoaderMock)(c)
})

// Act
Expand Down
2 changes: 1 addition & 1 deletion internal/app/action/loading_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestLoadCustomerById(t *testing.T) {
w := httptest.NewRecorder()

r.GET("/customer/:id", func(c *gin.Context) {
LoadCustomerById(c, customerLoaderMock)
LoadCustomerById(customerLoaderMock)(c)
})

// Act
Expand Down
6 changes: 3 additions & 3 deletions internal/app/action/saving_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestSaveCustomer_FailOnBindJson(t *testing.T) {
w := httptest.NewRecorder()

r.POST("/customer", func(c *gin.Context) {
SaveCustomer(c, customerSaverMock)
SaveCustomer(customerSaverMock)(c)
})

// Act
Expand Down Expand Up @@ -80,7 +80,7 @@ func TestSaveCustomer_FailOnSave(t *testing.T) {
w := httptest.NewRecorder()

r.POST("/customer", func(c *gin.Context) {
SaveCustomer(c, customerSaverMock)
SaveCustomer(customerSaverMock)(c)
})

// Act
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestSaveCustomer_HappyPath(t *testing.T) {
w := httptest.NewRecorder()

r.POST("/customer", func(c *gin.Context) {
SaveCustomer(c, customerSaverMock)
SaveCustomer(customerSaverMock)(c)
})

// Act
Expand Down
Loading

0 comments on commit fb2527b

Please sign in to comment.