mirror of
https://github.com/MrOkiDoki/BattleBit-Community-Server-API.git
synced 2025-01-09 11:17:30 -03:00
Add docker support
This commit is contained in:
parent
1caa609a55
commit
e698acae60
4 changed files with 231 additions and 1 deletions
171
.dockerignore
Normal file
171
.dockerignore
Normal file
|
@ -0,0 +1,171 @@
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
|
||||||
|
# Visual Studio 2015 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUNIT
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_i.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# JustCode is a .NET coding add-in
|
||||||
|
.JustCode
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
**/packages/*
|
||||||
|
!**/packages/build/
|
||||||
|
# NuGet v3's project.json files produces more ignoreable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
.idea/
|
||||||
|
*.sln.iml
|
||||||
|
|
||||||
|
# CodeRush
|
||||||
|
.cr/
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
tools/Cake.CoreCLR
|
||||||
|
.vscode
|
||||||
|
.dotnet
|
||||||
|
Dockerfile
|
||||||
|
|
||||||
|
# .env file contains default environment variables for docker
|
||||||
|
.env
|
||||||
|
.git
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -164,7 +164,7 @@ __pycache__/
|
||||||
tools/Cake.CoreCLR
|
tools/Cake.CoreCLR
|
||||||
.vscode
|
.vscode
|
||||||
.dotnet
|
.dotnet
|
||||||
Dockerfile
|
# Dockerfile
|
||||||
|
|
||||||
# .env file contains default environment variables for docker
|
# .env file contains default environment variables for docker
|
||||||
.env
|
.env
|
||||||
|
|
43
Dockerfile
Normal file
43
Dockerfile
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# This is a multi-stage Dockerfile, in this case it means that
|
||||||
|
# we use a "heavy" SDK image with all compiler tools to build the application, but
|
||||||
|
# then only use the runtime and generated binaries when actually running the app.
|
||||||
|
# This allows us to make the resulting image much smaller in size.
|
||||||
|
|
||||||
|
# We start off by using the SDK to build the application
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
# We first copy ONLY the project definition file, instead of all files at once.
|
||||||
|
# This prevents us from having to restore all dependencies (slow) every time
|
||||||
|
# we build, since every step in the Dockerfile build process is reusable. So
|
||||||
|
# if only our code changes, but our project file (incl. dependencies) does not,
|
||||||
|
# we can skip these two steps before recompiling, saving us quite some time.
|
||||||
|
COPY ["CommunityServerAPI.csproj", "./"]
|
||||||
|
RUN dotnet restore "CommunityServerAPI.csproj"
|
||||||
|
|
||||||
|
# Now we can copy all source files (except those listed in `.dockerignore`)
|
||||||
|
# and build the application
|
||||||
|
COPY [".", "./"]
|
||||||
|
RUN dotnet build "CommunityServerAPI.csproj" --no-restore -c Release -o /app
|
||||||
|
|
||||||
|
|
||||||
|
##########
|
||||||
|
# The next step is to take the built/compiled source code and package it
|
||||||
|
# into a single "publishable" binary
|
||||||
|
FROM build as publish
|
||||||
|
RUN dotnet publish "CommunityServerAPI.csproj" -c Release -o /app
|
||||||
|
|
||||||
|
#########
|
||||||
|
# Then, we start over with a completely new environment
|
||||||
|
# that just contains the .NET runtime. Here, we copy over the
|
||||||
|
# built and packaged binary files from the other environment to be able to run it.
|
||||||
|
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS final
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# We expose port 29294 as the default port on which our app runs.
|
||||||
|
EXPOSE 29294
|
||||||
|
|
||||||
|
COPY --from=publish /app .
|
||||||
|
|
||||||
|
# Set the default action when the container is started, which in this case runs the API.
|
||||||
|
ENTRYPOINT [ "dotnet", "CommunityServerAPI.dll" ]
|
16
docker-compose.yml
Normal file
16
docker-compose.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
# In the docker compose file, we define some services (containers) to run.
|
||||||
|
# This will be geared towards production.
|
||||||
|
services:
|
||||||
|
|
||||||
|
battlebit-community-api:
|
||||||
|
image: bb-cummunity-server-api:latest
|
||||||
|
build:
|
||||||
|
# Specify how to build the image above.
|
||||||
|
context: .
|
||||||
|
target: build
|
||||||
|
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "29294:29294"
|
Loading…
Reference in a new issue