Add docker-compose file (#466)

This commit is contained in:
Jakob Gillich 2020-05-26 22:19:44 +02:00 committed by GitHub
parent 341d7d413c
commit 6ca72ecb41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 4 deletions

View file

@ -27,7 +27,13 @@ by following the *[PSForever Server Connection Guide](https://docs.google.com/do
PSF-LoginServer is writen in [Scala](https://www.scala-lang.org/) and built using SBT, which allows it to be built on any platform. SBT is the Scala version of Make, but is more powerful as build definitions are written in Scala. SBT is distributed as a Java JAR and the only dependency it has is a JDK. [Follow the quick instructions on Scala's home page](https://www.scala-lang.org/download/) to get a working development environment and come back when you are done. PSF-LoginServer is writen in [Scala](https://www.scala-lang.org/) and built using SBT, which allows it to be built on any platform. SBT is the Scala version of Make, but is more powerful as build definitions are written in Scala. SBT is distributed as a Java JAR and the only dependency it has is a JDK. [Follow the quick instructions on Scala's home page](https://www.scala-lang.org/download/) to get a working development environment and come back when you are done.
In order to compile scala, `scalac` is used behind the scenes. This is equivalent to Java's `javac`, but for the Scala language. In order to compile scala, `scalac` is used behind the scenes. This is equivalent to Java's `javac`, but for the Scala language.
Scala runs on top of the Java Virtual Machine, meaning it generates `.class` and `.jar` files and uses the `java` executable. Essentially, Scala is just a compiler that targets the JVM, which is its runtime. All of this runs in the background and is packaged automatically by your IDE or SBT, which automatically downloads the right version of the Scala compiler for you. Scala runs on top of the Java Virtual Machine, meaning it generates `.class` and `.jar` files and
uses the `java` executable. Essentially, Scala is just a compiler that targets the JVM, which is its
runtime. All of this runs in the background and is packaged automatically by your IDE or SBT, which
automatically downloads the right version of the Scala compiler for you.
If you have Docker and docker-compose installed on your system, you can get a complete development
environment up by running `docker-compose up` in the source code directory. Otherwise, keep reading.
### Using an IDE ### Using an IDE
Scala code can be fairly complex and a good IDE helps you understand the code and what methods are available for certain types, especially as you are learning the language. Scala code can be fairly complex and a good IDE helps you understand the code and what methods are available for certain types, especially as you are learning the language.

36
docker-compose.yml Normal file
View file

@ -0,0 +1,36 @@
version: "3"
services:
loginserver:
image: mozilla/sbt:8u232_1.3.8
volumes:
- .:/PSF-Loginserver:z
working_dir: /PSF-Loginserver
depends_on:
- db
ports:
- 51000-51001:51000-51001/udp
- 51002:51002/tcp
command: >
sh -c '
if [ ! -f "config/worldserver.ini" ]; then
sed "s/Hostname = \"localhost\"/Hostname = \"db\"/g" config/worldserver.ini.dist > config/worldserver.ini
fi
if [ ! -d "pscrypto-lib" ]; then
wget https://github.com/psforever/PSCrypto/releases/download/v1.1/pscrypto-lib-1.1.zip
unzip pscrypto-lib-1.1.zip
rm pscrypto-lib-1.1.zip
fi
sbt pslogin/run
'
adminer:
image: adminer
ports:
- 51010:8080
db:
image: postgres
volumes:
- ./schema.sql:/docker-entrypoint-initdb.d/schema.sql:z
environment:
POSTGRES_USER: psforever
POSTGRES_PASSWORD: psforever
POSTGRES_DATABASE: psforever