Skip to content

Commit

Permalink
Add Docker build files and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
violet committed Sep 19, 2024
1 parent b6c1277 commit 97a00a0
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mssql-data
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@ Code contributions from others are welcome, although the creators retain the rig

## Installation

The server, client and database can be easily ran in Docker:

- Install [Docker](https://docker.com/) and docker-compose (generally included in a docker installation)
- Clone the repository
- Run: `docker compose build frontend backend`
- Run: `docker compose up -d`
- Access the game frontend at http://localhost:5173

Database files will be stored in `mssql-data` directory.

To read the server logs, run `docker compose logs -f backend`.

To update the code in the future, run these commands:
```
docker compose down -rmi
git pull
docker compose build frontend backend
docker compose up -d
```

If you cannot use Docker or would like a development setup, follow the instructions below.

## Development setup

The two components - found in the `server` and `client` directories - may be run together or independently. The client always requires a server instance (local or remote) for the game to function beyond the welcome and setup screens.

The `prototype` directory contains the original proof of concept from 2021. None of its contents are required for running the latest version of 5D Diplomacy.
Expand Down
8 changes: 8 additions & 0 deletions client/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
http://:8080 {
file_server /* {
root /dist
}
handle_path /api/* {
reverse_proxy http://backend:8080
}
}
18 changes: 18 additions & 0 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM alpine:latest AS builder

RUN apk add nodejs yarn

WORKDIR /app
COPY . .

RUN yarn
RUN VITE_SERVER_URL=/api yarn build

FROM alpine:latest

RUN apk add caddy
COPY Caddyfile /etc/Caddyfile

COPY --from=builder /app/dist /dist

ENTRYPOINT [ "caddy", "run", "-c", "/etc/Caddyfile" ]
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
frontend:
build: client/
ports:
- 127.0.0.1:5173:8080
restart: always
backend:
build: server/
environment:
- "ConnectionStrings__Database=Server=mssql;Database=diplomacy;User=SA;Password=Passw0rd@;Encrypt=True;TrustServerCertificate=True"
restart: always
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
user: root
environment:
- ACCEPT_EULA=y
- "MSSQL_SA_PASSWORD=Passw0rd@"
volumes:
- './mssql-data/data:/var/opt/mssql/data'
- './mssql-data/log:/var/opt/mssql/log'
- './mssql-data/secrets:/var/opt/mssql/secrets'
1 change: 1 addition & 0 deletions server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/
10 changes: 10 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /app

COPY . /app
RUN dotnet build -c Release -o bin

RUN dotnet tool install --global dotnet-ef

CMD ["/app/docker-entrypoint.sh"]
1 change: 0 additions & 1 deletion server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
.AllowAnyMethod());
}

app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
1 change: 0 additions & 1 deletion server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
Expand Down
5 changes: 5 additions & 0 deletions server/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

~/.dotnet/tools/dotnet-ef database update

dotnet /app/bin/5dDiplomacyWithMultiverseTimeTravel.dll

0 comments on commit 97a00a0

Please sign in to comment.