Skip to content

Commit

Permalink
local environment
Browse files Browse the repository at this point in the history
  • Loading branch information
hasipon committed Jan 9, 2025
1 parent b43dea0 commit dc6e06f
Show file tree
Hide file tree
Showing 75 changed files with 1,601 additions and 2 deletions.
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# 天下一 Game Battle Contest 2024

- [公式サイト](https://tenka1.klab.jp/2024/)
- [ポータルサイト](https://2024.gcp.tenka1.klab.jp/portal/index.html)
- [YouTube配信](https://www.youtube.com/watch?v=jYSpojU0xXU)

## ドキュメント
Expand Down Expand Up @@ -32,6 +31,43 @@
- [各ゲームの結果](result/ranking.tsv)
- [各ゲームの入出力](https://tenka1.klab.jp/2024/result.zip) (106.8 MiB)


## ローカル実行
ゲームサーバーを動作させるdockerファイルを用意しました。

docker をインストールした環境で、以下のコマンドを実行してください。

起動
```
$ docker compose up
```

ユーザー登録
```
# ユーザID: user0001 トークン: token0001 のユーザーを作成
$ docker compose exec gamedb redis-cli HSET user_token token0001 user0001
```

以下のURLでAPI、SVGビジュアライザ、WebGLビジュアライザにアクセス可能です。
- http://localhost:8080/api/state/token0001
- http://localhost:8080/portal/index.html
- http://localhost:8080/visualizer/index.html?user_id=user0001&token=token0001

BOTプログラムはGAME_SERVERのURLとして `http://localhost:8080` を設定してください。


## ビジュアライザで使用したライブラリ等
- SVGビジュアライザ
- [license.csv](lb/portal/license.csv) を参照してください。

- WebGLビジュアライザ本体 © 2024 KLab Inc. All rights reserved.
- Game BGM and SE by KLab Sound Team © 2023 KLab Inc. All rights reserved.
- [Hurisake.JsonDeserializer by hasipon](https://github.com/hasipon/Hurisake.JsonDeserializer)
- [TextShader(MIT) © gam0022](https://qiita.com/gam0022/items/f3b7a3e9821a67a5b0f3)
- [Rajdhani (OFL) © Indian Type Foundry](https://fonts.google.com/specimen/Rajdhani)
- [Courier Prime (OFL) © The Courier Prime Project Authors](https://fonts.google.com/specimen/Courier+Prime)
- [Source Sans 3 (OFL) © 2010-2020 Adobe](https://fonts.google.com/specimen/Source+Sans+3)

## ルール

- コンテスト期間
Expand Down
37 changes: 37 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
services:
gamedb:
image: redis:5.0.5
volumes:
- gamedbvolume:/data

game:
build:
context: ./game
command: uvicorn main:app --host 0.0.0.0 --port 8080 --reload
restart: on-failure
environment:
- GAMEDB_HOST=gamedb
- GAMEDB_PORT=6379
- API_PORT=8080

batch:
build:
context: ./game
command: python -c 'import batch; batch.main()'
restart: on-failure
environment:
- GAMEDB_HOST=gamedb
- GAMEDB_PORT=6379

lb:
build: ./lb
depends_on:
- game
ports:
- 8080:80
volumes:
- ./lb/nginx.conf:/etc/nginx/nginx.conf
- ./lb/mime.types:/etc/nginx/mime.types

volumes:
gamedbvolume:
9 changes: 9 additions & 0 deletions game/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.12
WORKDIR /game
COPY ./requirements.txt /game/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /game/requirements.txt
COPY ./evaluate.cpp /game/evaluate.cpp
RUN g++ evaluate.cpp -O2 -o evaluate
COPY . /game

CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${API_PORT:-8000}"]
Loading

0 comments on commit dc6e06f

Please sign in to comment.