mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-25 04:35:18 +00:00
Provide docker image (#6)
* add Dockerfile * add docker-compose.yml * Github workflow to build and deploy docker image * workdir /data/ instead of /app/ * use a local directory instead of a named volume This makes the settings.json more accessible from the outside by default, but is less portable. The -v command with $PWD might not work on native Windows shells, but rather wants an absolute Windows path like C:\User\... or /c/User/... And on Linux, because the /data/ directory and the settings.json will be owned by root. Though that can be changed. * more docker-compose command examples * add linux/arm/v7 ; improve build & runtime * fix: just arm not arm32 * test docker build for PRs * back to the microsoft runtime
This commit is contained in:
parent
b5a6a87649
commit
ccccdecb6a
5 changed files with 199 additions and 0 deletions
74
.github/workflows/deploy.yml
vendored
Normal file
74
.github/workflows/deploy.yml
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
name: Build and deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
tags:
|
||||
- '*.*.*'
|
||||
- 'v*.*.*'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
IMAGE: ${{ github.repository_owner }}/smo-online-server
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Environment
|
||||
run: |
|
||||
IMAGE=`echo ${{ env.IMAGE }} | tr '[:upper:]' '[:lower:]'`
|
||||
echo "IMAGE=$IMAGE" >>$GITHUB_ENV
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
id: meta
|
||||
name: Docker meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/${{ env.IMAGE }}
|
||||
flavor: |
|
||||
latest=false
|
||||
tags: |
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=semver,pattern={{major}}.{{minor}}.{{patch}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=ref,event=branch
|
||||
labels: |
|
||||
org.opencontainers.image.licenses=UNLICENSED
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
with:
|
||||
platforms: amd64,arm64,arm
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to GHCR
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry : ghcr.io
|
||||
username : ${{ github.repository_owner }}
|
||||
password : ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
pull : true
|
||||
push : true
|
||||
context : .
|
||||
file : ./Dockerfile
|
||||
tags : ${{ steps.meta.outputs.tags }}
|
||||
labels : ${{ steps.meta.outputs.labels }}
|
||||
platforms : linux/amd64,linux/arm/v7,linux/arm64/v8
|
||||
cache-from : type=gha,scope=${{ github.workflow }}
|
||||
cache-to : type=gha,scope=${{ github.workflow }},mode=max
|
37
.github/workflows/test-pr.yml
vendored
Normal file
37
.github/workflows/test-pr.yml
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
name: Test PR
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- '**'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
with:
|
||||
platforms: amd64,arm64,arm
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Build
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
pull : true
|
||||
push : false
|
||||
context : .
|
||||
file : ./Dockerfile
|
||||
platforms : linux/amd64,linux/arm/v7,linux/arm64/v8
|
||||
cache-from : type=gha,scope=${{ github.workflow }}
|
||||
cache-to : type=gha,scope=${{ github.workflow }},mode=max
|
45
Dockerfile
Normal file
45
Dockerfile
Normal file
|
@ -0,0 +1,45 @@
|
|||
################################################################################
|
||||
################################################################## build ###
|
||||
|
||||
FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/sdk:6.0 as build
|
||||
|
||||
WORKDIR /app/
|
||||
|
||||
COPY ./Server/ ./Server/
|
||||
COPY ./Shared/ ./Shared/
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
# Download NuGet dependencies
|
||||
RUN dotnet restore \
|
||||
./Server/Server.csproj \
|
||||
-r debian.11-`echo $TARGETARCH | sed 's@^amd@x@'` \
|
||||
;
|
||||
|
||||
# Build application binary
|
||||
RUN dotnet publish \
|
||||
./Server/Server.csproj \
|
||||
-r debian.11-`echo $TARGETARCH | sed 's@^amd@x@'` \
|
||||
-c Release \
|
||||
-o ./out/ \
|
||||
--no-restore \
|
||||
--self-contained \
|
||||
-p:publishSingleFile=true \
|
||||
;
|
||||
|
||||
################################################################## build ###
|
||||
################################################################################
|
||||
################################################################ runtime ###
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/runtime:6.0 as runtime
|
||||
|
||||
# Copy application binary from build stage
|
||||
COPY --from=build /app/out/ /app/
|
||||
|
||||
ENTRYPOINT [ "/app/Server" ]
|
||||
EXPOSE 1027/tcp
|
||||
WORKDIR /data/
|
||||
VOLUME /data/
|
||||
|
||||
################################################################ runtime ###
|
||||
################################################################################
|
31
README.md
31
README.md
|
@ -4,6 +4,7 @@ The official server for the [Super Mario Odyssey: Online](https://github.com/Cra
|
|||
|
||||
|
||||
## Windows Setup
|
||||
|
||||
1. Download latest build from [Releases](https://github.com/Sanae6/SmoOnlineServer/releases)
|
||||
2. Run `Server.exe`
|
||||
3. `settings.json` is autogenerated in step 2, modify it however you'd like.
|
||||
|
@ -30,6 +31,36 @@ chmod +x filepath to the server executable
|
|||
systemctl enable --now smo.service
|
||||
```
|
||||
|
||||
## Run docker image
|
||||
|
||||
If you have [docker](https://docs.docker.com/) on your system, you can use the existing docker image.
|
||||
That way you don't have to build this server yourself or manually handle executables.
|
||||
|
||||
```shell
|
||||
docker run --rm -it -p 1027:1027 -v "/$PWD/data/://data/" ghcr.io/sanae6/smo-online-server
|
||||
# on Windows, depending on the shell you're using, $PWD might not work. Use an absolute path instead.
|
||||
```
|
||||
|
||||
To always check for and use the latest server version you can add `--pull=always` to the options.
|
||||
|
||||
Alternatively there's a `docker-compose.yml` for [docker-compose](https://docs.docker.com/compose/) to simplify the command line options:
|
||||
```shell
|
||||
# update server
|
||||
docker-compose pull
|
||||
|
||||
# start server
|
||||
docker-compose up -d
|
||||
|
||||
# open the server cli
|
||||
docker attach `docker-compose ps -q` --sig-proxy=false
|
||||
|
||||
# watch server logs
|
||||
docker-compose logs --tail=20 --follow
|
||||
|
||||
# stop server
|
||||
docker-compose stop
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
||||
Run `help` to get what commands are available in the server console.
|
||||
|
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
version: "3.9"
|
||||
|
||||
services:
|
||||
server:
|
||||
image: ghcr.io/sanae6/smo-online-server
|
||||
#build: .
|
||||
#user: 1000:1000
|
||||
stdin_open: true
|
||||
ports:
|
||||
- 1027:1027
|
||||
volumes:
|
||||
- ./data/:/data/
|
Loading…
Reference in a new issue