From 639fe15957f7db891ce0a67b7901f3bbb50bcbd2 Mon Sep 17 00:00:00 2001 From: CommonLoon102 <321850+CommonLoon102@users.noreply.github.com> Date: Sat, 1 Feb 2020 20:35:53 +0000 Subject: [PATCH] optimize Dockerfile (#13) * optimize dockerfile * fix syntax --- Dockerfile | 38 +++++++++++++++++++++----------------- README.md | 2 +- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 441ad42..6970255 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,12 +34,28 @@ RUN dotnet_sdk_version=3.1.101 \ # Trigger first run experience by running arbitrary cmd && dotnet help +# Install toolchain to build NBlood and the supervisor +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + build-essential \ + git \ + libgl1-mesa-dev \ + libglu1-mesa-dev \ + libsdl-mixer1.2-dev \ + libsdl1.2-dev \ + libsdl2-dev \ + libsdl2-mixer-dev \ + nano \ + nasm \ + nginx \ + && rm -rf /var/lib/apt/lists/* + # Installing the NBlood supervisor related things WORKDIR /supervisor RUN mkdir -p publish/blood -RUN apt-get update && apt-get install -y \ - git \ - nano + +# Disable cache from this point +ARG CACHEBUST # Clone NBloodServerSupervisor RUN git clone https://github.com/CommonLoon102/NBloodServerSupervisor.git @@ -48,17 +64,6 @@ RUN git clone https://github.com/CommonLoon102/NBloodServerSupervisor.git RUN dotnet publish NBloodServerSupervisor/NBloodServerSupervisor.sln --configuration Release --output publish --self-contained false --runtime linux-x64 \ && sed -i -e "s/CHANGEME/$(< /dev/urandom tr -dc A-Za-z0-9 | head -c${1:-32};echo;)/g" publish/appsettings.json -# Install toolchain to build NBlood -RUN apt-get update && apt-get install -y \ - build-essential \ - libgl1-mesa-dev \ - libglu1-mesa-dev \ - libsdl-mixer1.2-dev \ - libsdl1.2-dev \ - libsdl2-dev \ - libsdl2-mixer-dev \ - nasm - # Clone NBlood RUN git clone https://github.com/CommonLoon102/NBlood.git @@ -67,9 +72,8 @@ RUN cd NBlood \ && git checkout norender \ && make blood NORENDER=1 -# Install and configure nginx -RUN apt-get update && apt-get install -y nginx \ - && printf '\ +# Configure nginx +RUN printf '\ server { \n\ listen 23580; \n\ location / { \n\ diff --git a/README.md b/README.md index e4ff5ad..3692e98 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ After you start the container, the following will happen: ## Deploy the server onto GNU/Linux 1. Install Docker and wget (if you don't have already), for example like this: `sudo snap install docker && sudo apt install wget -y` 2. Download the Dockerfile: `wget https://raw.githubusercontent.com/CommonLoon102/NBloodServerSupervisor/master/Dockerfile --directory-prefix=supervisor` -3. Build the Docker image: `sudo docker build --no-cache -t nblood-supervisor:latest supervisor` +3. Build the Docker image: `sudo docker build --build-arg CACHEBUST=$(date +%s) -t nblood-supervisor:latest supervisor` 4. Navigate to your Blood 1.21 directory where you have the below files. The files are from stock Blood 1.21, Cryptic Passage, Death Wish 1.6.10 and The Way of Ira 1.0.1 - BLOOD.INI