Latiosu feat/docker (#5572)
* Add dockerised local development environment * Enable tini (--init) for server container See https://docs.docker.com/compose/compose-file/#init for details * Add local development environment documentation * Add a tip for how-to connect a client on the same machine * Add specialized tools/docker folder Co-authored-by: Eric <latiosworks@gmail.com>
This commit is contained in:
parent
f97dd6e85f
commit
629c7b50f3
8
.github/CONTRIBUTING.md
vendored
8
.github/CONTRIBUTING.md
vendored
@ -7,6 +7,7 @@ Table of Contents
|
||||
* [Reporting Bugs](#reporting-bugs)
|
||||
* [Suggesting Enhancements](#suggesting-enhancements)
|
||||
* [Issue Labels](#issue-labels)
|
||||
* [Local Development Environment](#local-development-environment)
|
||||
* [Become a Team Member](#become-a-team-member)
|
||||
|
||||
Reporting Bugs
|
||||
@ -161,6 +162,13 @@ For the most part you as a user will have no reason to worry about the **Milesto
|
||||
[search-rathena-label-typemaintenance]: https://github.com/rathena/rathena/issues?q=is%3Aissue+is%3Aopen+label%3Atype%3Amaintenance
|
||||
[search-rathena-label-typequestion]: https://github.com/rathena/rathena/issues?q=is%3Aissue+is%3Aopen+label%3Atype%3Aquestion
|
||||
|
||||
Local Development Environment
|
||||
-----------------------------
|
||||
|
||||
Developers can get up and running quickly with a Dockerized development environment that installs all dependencies needed to run and develop on rAthena.
|
||||
See tools/docker/README.md for details
|
||||
|
||||
|
||||
Become a Team Member
|
||||
--------------------
|
||||
|
||||
|
4
tools/docker/Dockerfile
Normal file
4
tools/docker/Dockerfile
Normal file
@ -0,0 +1,4 @@
|
||||
FROM alpine:3.11
|
||||
WORKDIR /rathena
|
||||
RUN apk add --no-cache git cmake make gcc g++ gdb zlib-dev mariadb-dev ca-certificates linux-headers bash
|
||||
ENTRYPOINT [ "bash" ]
|
29
tools/docker/README.md
Normal file
29
tools/docker/README.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Docker
|
||||
|
||||
Note that this Dockerized environment **is not suitable** for production deployments, see [Installations](https://github.com/rathena/rathena/wiki/installations) instead.
|
||||
|
||||
### How to setup a local development environment :computer:
|
||||
|
||||
1. `docker-compose up -d` to spin up dev container and database (ensure port `3306` is free)
|
||||
2. `docker exec -it rathena bash` to connect to dev container
|
||||
3. All rAthena development commands can be executed inside the dev container, such as compiling (`./configure`, `make clean server`) and starting the server (`./athena-start`, `gdb map-server`, etc ...)
|
||||
4. `docker-compose down` outside the dev container when done to close database and free resources
|
||||
|
||||
#### Tips & tricks for local development :beginner:
|
||||
|
||||
- Ensure you don't have a database running locally and listening on port `3306` this will cause the database container to fail starting up.
|
||||
- All file edits within the repository are reflected inside the container, so you can develop in your preferred text editor or IDE.
|
||||
- Files into ./asset take precedence over conf/import/ counterpart
|
||||
- Connect to the local database with following credentials:
|
||||
- Host: `localhost`
|
||||
- Port: `3306`
|
||||
- User: `ragnarok`
|
||||
- Password: `ragnarok`
|
||||
- On first start up all `/sql-files/*.sql` files are imported into the database. This does not happen on future start ups unless the volume has been deleted.
|
||||
- Database is saved to local disk so state is persisted between shutdowns and start ups. To fully erase your database and start fresh, delete the volume with `docker-compose down --volumes`
|
||||
- Check the status of containers with `docker-compose ps`
|
||||
- If you have modified the `Dockerfile`, be sure to rebuild the docker image with `docker-compose build`
|
||||
|
||||
### F.A.Q
|
||||
|
||||
`ls: can't open '.': Permission denied` turn off selinux.
|
2
tools/docker/asset/char_conf.txt
Normal file
2
tools/docker/asset/char_conf.txt
Normal file
@ -0,0 +1,2 @@
|
||||
login_ip: 127.0.0.1
|
||||
char_ip: 127.0.0.1
|
5
tools/docker/asset/inter_conf.txt
Normal file
5
tools/docker/asset/inter_conf.txt
Normal file
@ -0,0 +1,5 @@
|
||||
login_server_ip: db
|
||||
ipban_db_ip: db
|
||||
char_server_ip: db
|
||||
map_server_ip: db
|
||||
log_db_ip: db
|
2
tools/docker/asset/map_conf.txt
Normal file
2
tools/docker/asset/map_conf.txt
Normal file
@ -0,0 +1,2 @@
|
||||
char_ip: 127.0.0.1
|
||||
map_ip: 127.0.0.1
|
39
tools/docker/docker-compose.yml
Normal file
39
tools/docker/docker-compose.yml
Normal file
@ -0,0 +1,39 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
db:
|
||||
image: "mariadb:bionic"
|
||||
container_name: "rathena_db"
|
||||
ports:
|
||||
- "3306:3306" # allow DB connections from host
|
||||
volumes:
|
||||
- "rathenadb:/var/lib/mysql" # save database to local disk
|
||||
- "../../sql-files/:/docker-entrypoint-initdb.d" # initialize db with ./sql-files
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ragnarok
|
||||
MYSQL_DATABASE: ragnarok
|
||||
MYSQL_USER: ragnarok
|
||||
MYSQL_PASSWORD: ragnarok
|
||||
server:
|
||||
image: "rathena:local"
|
||||
container_name: "rathena"
|
||||
ports:
|
||||
- "5121:5121" # map server
|
||||
- "6121:6121" # char server
|
||||
- "6900:6900" # login server
|
||||
volumes:
|
||||
- "../..:/rathena" # mount git repo directory inside container
|
||||
- "./asset/inter_conf.txt:/rathena/conf/import/inter_conf.txt" # load db connection
|
||||
- "./asset/char_conf.txt:/rathena/conf/import/char_conf.txt" #localdev login-char relation
|
||||
- "./asset/map_conf.txt:/rathena/conf/import/map_conf.txt" #localdev char-map relation
|
||||
init: true # helps with signal forwarding and process reaping
|
||||
tty: true
|
||||
stdin_open: true
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
volumes:
|
||||
rathenadb:
|
Loading…
x
Reference in New Issue
Block a user