Initial docker test

Signed-off-by: xavo95 <xavo95@xeondev.com>
This commit is contained in:
a 2024-09-11 20:26:09 +02:00 committed by xavo95
parent 099ac9f871
commit 9afba329c2
Signed by: xavo95
GPG key ID: CBF8ADED6DEBB783
13 changed files with 174 additions and 0 deletions

12
.dockerignore Normal file
View file

@ -0,0 +1,12 @@
.git
assets
postgres
**/target
.gitignore
docker-compose.yml
Dockerfile-builder
Dockerfile-service
LICENSE
*.md
*.zip
*.png

6
Dockerfile-builder Normal file
View file

@ -0,0 +1,6 @@
FROM rust:1.81-alpine3.20
WORKDIR /app
COPY . .
# No need to manually strip symbols(strip target/release/$MICROSERVICE) since workspace its already prepared for that
RUN apk add musl-dev protoc && cargo build --release

6
Dockerfile-service Normal file
View file

@ -0,0 +1,6 @@
FROM alpine:3.20 as release
ARG MICROSERVICE
WORKDIR /app
COPY --from=shorekeeper-builder:1.3.0-SNAPSHOT /app/target/release/$MICROSERVICE ./service
CMD ["./service"]

View file

@ -0,0 +1,6 @@
[network]
http_addr = "0.0.0.0:10001"
[encryption]
key = "t+AEu5SGdpz06tomonajLMau9AJgmyTvVhz9VtGf1+0="
iv = "fprc5lBWADQB7tim0R2JxQ=="

View file

@ -0,0 +1,13 @@
service_id = 2
[database]
host = "shorekeeper-postgres:5432"
user_name = "shorekeeper_user"
password = "shorekeeper_pass"
db_name = "shorekeeper_db"
[service_end_point]
addr = "tcp://0.0.0.0:10004"
[gateway_end_point]
addr = "tcp://shorekeeper-gateway-server:10003"

View file

@ -0,0 +1,20 @@
service_id = 1
[network]
kcp_port = 7777
[protokey]
builtin_encryption_msg_id = [111, 112]
use_client_key = true
[service_end_point]
addr = "tcp://0.0.0.0:10003"
[game_server_end_point]
addr = "tcp://shorekeeper-game-server:10004"
[database]
host = "shorekeeper-postgres:5432"
user_name = "shorekeeper_user"
password = "shorekeeper_pass"
db_name = "shorekeeper_db"

View file

@ -0,0 +1,6 @@
[network]
http_addr = "0.0.0.0:10002"
[encryption]
key = "t+AEu5SGdpz06tomonajLMau9AJgmyTvVhz9VtGf1+0="
iv = "fprc5lBWADQB7tim0R2JxQ=="

View file

@ -0,0 +1,12 @@
[network]
http_addr = "0.0.0.0:5500"
[gateway]
host = "shorekeeper-gateway-server"
port = 7777
[database]
host = "shorekeeper-postgres:5432"
user_name = "shorekeeper_user"
password = "shorekeeper_pass"
db_name = "shorekeeper_db"

View file

@ -0,0 +1,3 @@
CREATE DATABASE shorekeeper_db;
CREATE USER shorekeeper_user WITH encrypted password 'shorekeeper_pass';
GRANT ALL PRIVILEGES ON DATABASE shorekeeper_db to shorekeeper_user;

View file

@ -0,0 +1,2 @@
\c shorekeeper_db;
GRANT ALL ON SCHEMA public TO shorekeeper_user;

9
builder.bat Normal file
View file

@ -0,0 +1,9 @@
docker build -t shorekeeper-builder:1.3.0-SNAPSHOT -f Dockerfile-builder .
docker build -t shorekeeper-config-server:1.3.0-SNAPSHOT --build-arg MICROSERVICE=config-server -f Dockerfile-service .
docker build -t shorekeeper-hotpatch-server:1.3.0-SNAPSHOT --build-arg MICROSERVICE=hotpatch-server -f Dockerfile-service .
docker build -t shorekeeper-login-server:1.3.0-SNAPSHOT --build-arg MICROSERVICE=login-server -f Dockerfile-service .
docker build -t shorekeeper-gateway-server:1.3.0-SNAPSHOT --build-arg MICROSERVICE=gateway-server -f Dockerfile-service .
docker build -t shorekeeper-game-server:1.3.0-SNAPSHOT --build-arg MICROSERVICE=game-server -f Dockerfile-service .
docker rmi shorekeeper-builder:1.3.0-SNAPSHOT

9
builder.sh Normal file
View file

@ -0,0 +1,9 @@
docker build -t shorekeeper-builder:1.3.0-SNAPSHOT -f Dockerfile-builder .
docker build -t shorekeeper-config-server:1.3.0-SNAPSHOT --build-arg MICROSERVICE=config-server -f Dockerfile-service .
docker build -t shorekeeper-hotpatch-server:1.3.0-SNAPSHOT --build-arg MICROSERVICE=hotpatch-server -f Dockerfile-service .
docker build -t shorekeeper-login-server:1.3.0-SNAPSHOT --build-arg MICROSERVICE=login-server -f Dockerfile-service .
docker build -t shorekeeper-gateway-server:1.3.0-SNAPSHOT --build-arg MICROSERVICE=gateway-server -f Dockerfile-service .
docker build -t shorekeeper-game-server:1.3.0-SNAPSHOT --build-arg MICROSERVICE=game-server -f Dockerfile-service .
docker rmi shorekeeper-builder:1.3.0-SNAPSHOT

70
docker-compose.yml Normal file
View file

@ -0,0 +1,70 @@
name: shorekeeper-ps
services:
shorekeeper-config-server:
image: shorekeeper-config-server:1.3.0-SNAPSHOT
depends_on:
shorekeeper-postgres:
condition: service_healthy
ports:
- '10001:10001'
volumes:
- "./assets/docker/configserver.toml:/app/configserver.toml"
- "./assets/config:/app/assets/config"
shorekeeper-hotpatch-server:
image: shorekeeper-hotpatch-server:1.3.0-SNAPSHOT
depends_on:
shorekeeper-postgres:
condition: service_healthy
ports:
- '10002:10002'
volumes:
- "./assets/docker/hotpatch.toml:/app/hotpatch.toml"
- "./assets/hotpatch:/app/assets/hotpatch"
shorekeeper-login-server:
image: shorekeeper-login-server:1.3.0-SNAPSHOT
depends_on:
shorekeeper-postgres:
condition: service_healthy
ports:
- '5500:5500'
volumes:
- "./assets/docker/loginserver.toml:/app/loginserver.toml"
shorekeeper-gateway-server:
image: shorekeeper-gateway-server:1.3.0-SNAPSHOT
depends_on:
shorekeeper-postgres:
condition: service_healthy
ports:
# Uncomment this if you want to have manual access
# - '10003:10003'
- '7777:7777/udp'
volumes:
- "./assets/docker/gateway.toml:/app/gateway.toml"
shorekeeper-game-server:
image: shorekeeper-game-server:1.3.0-SNAPSHOT
depends_on:
shorekeeper-postgres:
condition: service_healthy
# Uncomment this if you want to have manual access
# ports:
# - '10004:10004'
volumes:
- "./assets/docker/gameserver.toml:/app/gameserver.toml"
- "./assets/logic:/app/assets/logic"
shorekeeper-postgres:
image: postgres:16.4-alpine3.20
user: postgres
# Uncomment this if you want to have manual access
# ports:
# - '5432:5432'
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
environment:
- "POSTGRES_PASSWORD=toor"
volumes:
# If you want to have persistence, mount postgres data folder
- "./assets/docker/postgres/scripts:/docker-entrypoint-initdb.d"