trying to resolve merge conflicts

This commit is contained in:
AHMZA
2022-05-30 19:30:07 +01:00
5 changed files with 265 additions and 19 deletions
+21 -1
View File
@@ -1,11 +1,31 @@
# use the classic alpine image
FROM alpine as Builder
RUN apk update && apk add curl git
# install curl and git
RUN apk add curl git
# download and unnzip the hugo binary then place it in /usr/local/bin
RUN curl -L https://github.com/gohugoio/hugo/releases/download/v0.92.2/hugo_0.92.2_Linux-ARM64.tar.gz > hugo.tar.gz && tar -zxf hugo.tar.gz && mv hugo /usr/local/bin
# clone the blog repository as well as the theme submodule
RUN git clone --recurse-submodules https://gitlab.com/AHMZA/blog.git
# set blog (the folder we just cloned) as the current DIR
WORKDIR blog
# Hugo generates the static files and minifies them
RUN hugo --minify
# Nginx image is as basic as we can get
FROM nginx
# copy the nginx.conf file
COPY --from=Builder /blog/nginx.conf /etc/nginx/nginx.conf
# copy the static files
COPY --from=Builder /blog/public/ /usr/share/nginx/html
# Tell the image to expose port 80 for HTTP
EXPOSE 80
+34 -16
View File
@@ -1,39 +1,57 @@
# blog-hugo
I am hoping to migrate my dynamic blog currently hosted using GHOST CMS
to a static site using HUGO.
This is probably the hundredth rendition of this site xD Previously to
using HUGO my blog was built using GHOST CMS which is a great platform
and is feature rich. However my problem came with the base design
philosophy of a CMS, relying on a Database.
HUGO is a static site generator meaning it takes a readable file format
like markdown and then compiles all that down into HTML (Static Files)
This removes the need for a database and in turn improves performance of
the site ten fold.
## Pros of static sites
* Security
* Reliability
* Speed
* Scalability
* Low Resource requirement
## Why
The reasons above all fit well with my current goal of trying to containerise
all of the services running on my home lab. Currently I have 2 servers running
Proxmox VE with a combined 48 threads and 256GB of RAM which as you can imagine
take a lot of power.
## Cons of a static site
The plan is to slowly move the majority of my services to a cluster of
4 RaspberryPis. If all the services required support the ARM CPU architecture
then I can completely decommission the power hungry servers.
* Less user friendly
## Why
The reasons above all fit within my goal of trying to containerise
services running in my home lab.
The plan is to move the services I use to a cluster of Raspberry Pis. As
long as the services have an ARM image or I can build an ARM image then
this is a viable solution
## How
I am still coming up with the deployment method of this site but from what I
have seen the Gitlab CI/CD pipeline makes a lot of sense as the site will be
hosted on Gitlab anyway.
* Update Gitlab with new code
* Gitlab generates a docker image
* Docker Swarm cluster uses that image to host the site
The deployment method of this site relies on the Gitlab CI/CD pipeline.
* Clone the repository
* Push changes to Gitlab
* Gitlab runners create the docker image
* Image is pushed to my private docker repository
* Pi cluster uses that image to host the site locally
## When Pulling / Cloning
Be sure to add `--recurse-submodules` as the theme used is a submodule
``` bash
git clone --recurse-submodules git@gitlab.com:AHMZA/blog.git
```
## Update the theme
As the theme is a submodule it will need to be update with the following
``` bash
git submodule update --remote --merge
```
+208
View File
@@ -0,0 +1,208 @@
---
title: Minecraft Server on Docker ⛏ 🐳
date: 2022-05-24T09:33:35+01:00
author: "ahmza"
draft: false
weight:
tags: ["Games", "Docker", "ARM"]
description: "Ever wanted to build a Minecraft server in docker !! Start here"
canonicalURL: "https://blog.ahmza.com/Page%28/posts/minecraft-server-on-docker.md%29"
cover:
image: "/webp/posts/mc-docker/feature-anim.webp" # image path/url
alt: "Minecraft Loves Docker" # alt text
caption: "<text>" # display caption under cover
relative: false # when using page bundles set this to true
showtoc: true
searchHidden: false
---
## **Introduction**
Minecraft is a great game and when it comes to multiplayer, a dedicated
server is the way to go (here's why[^1]). Myself and a few others
recently decided to start playing this game again, and I took the
opportunity to deploy the server in my lab.
A Minecraft server does not require a ton of resources to run, However
from my experience the more resources you can throw at it the better,
especially when you start to introduce mods and more than a few players.
I run our server on my main PC within WSL and Docker. This allows me to
leverage the system resources in my PC 🦾 leaving the [Pi Cluster](https://blog.ahmza.com/posts/building-a-docker-swarm-with-pis/)
to handle the rest of the stuff in my lab. The only reason I opted to
go this route is that I don’t want our server to be limited by hardware
resources as well as the Minecraft server effecting the overall
performance of the Pis.
## **Prerequisites**
- Docker
- Docker Compose
## **Requirements**[^2]
#### **Minimum (1-5 Players)**
- Intel Pentium 4 or AMD Athlon based CPU
- 512 MB RAM
- 2 GB Storage space
#### **Recommended (10-15 Players)**
- Intel Core or AMD K8 based CPU
- 3 GB RAM
- 16 GB Storage Space
#### **Optimal (20+ Players)**
- Intel i5/i7 or AMD Ryzen 5/7 Based CPU
- 6 GB RAM
- 35 GB Storage Space
## **Building the Container**
Now we have the formalities sorted, we can get to work on creating the
docker container for Minecraft.
1. **Create a directory in which you will keep the Minecraft server files**
- `mkdir minecraft-server`
- `cd minecraft-server`
2. **Create an environment file to be used by the Docker Container**
- The *.env* file allows us to specify variables which we can use
across the build process.
- `touch .env`
- Edit the file in a text editor, i.e. vim `vim .env`
```bash
CONTAINER_NAME=minecraft-server
SERVER_MEM=4096 #change this to your desired value (in MB)
SERVER_JAR=minecraft_server.1.18.2.jar
```
3. **Create the docker-compose.yml file**
- The *docker-compose.yml* file specifies the container that we
want to build, outlining the build context (Dockerfile),
setting the variables (from .env), configuring storage volumes
for persistence as well as ports and the container name.
- `touch docker-compose.yml`
- Edit the file in a text editor[^3], I.e. vim `vim docker-compose.yml`
```bash
version: "3"
services:
minecraft-server:
build:
context: .
args:
SERVER_MEM: ${SERVER_MEM}
SERVER_JAR: ${SERVER_JAR}
volumes:
- .server-data:/server
ports:
- 25565:25565
- 25575:25575
container_name: ${CONTAINER_NAME}
restart: unless-stopped
volumes:
server-data:
```
4. **Create the Dockerfile file**
- The Dockerfile builds the container. We take the 17-jre base
image apply our variables change the working directory to
/server and start the jar file, effectively starting the
Minecraft server.
- `touch Dockerfile`
- Edit the file in a text editor, i.e. vim `vim Dockerfile`
```bash
FROM eclipse-temurin:17-jre
ARG SERVER_MEM
ARG SERVER_JAR
ENV SERVER_MEM=${SERVER_MEM}
ENV SERVER_JAR=${SERVER_JAR}
WORKDIR /server
CMD echo "Minecraft Server is starting\n" && java -Xms128M -Xmx${SERVER_MEM}M -jar ${SERVER_JAR} nogui
```
## **Setup the Server files**
We’re almost there, just a few steps left !!
The curious among you may have realised when trying to start the
container that it fails with the error below:
```bash
Minecraft Server is starting
Error: Unable to access jarfile server.jar
```
This is because we have not downloaded the server jar file yet, that is
our next step.
1. **Navigate to one of the following sites:**[^4]
- [Vanilla Minecraft Server](https://www.minecraft.net/en-us/download/server) - instructions found here[^5]
- [Fabric Mod loader server](https://fabricmc.net/use/server/) - instructions found here [^6]
2. **Create a folder in the Minecraft-server folder called .server-data**
- `mkdir .server-data`
- `cd .server-data`
3. **Download the jar file - This will depend on the option above so read the instructions**
4. **Go back to the root minecraft-server folder**
- `cd ..`
5. **Run the container**
- `docker compose up` (use CTRL+C to exit)
- Once the server unpacks all the files you will see this:
```bash
minecraft-server | Starting net.minecraft.server.Main
minecraft-server | [18:05:50] [ServerMain/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
minecraft-server exited with code 0
```
7. **Accept the EULA**
- Go into the .server-data folder
1. `cd .server-data`
- Edit the file named eula.txt in a text editor i.e. vim `vim eula.txt`
1. Simply change `eula=false` to `eula=true`
8. **While in the .server-data folder make any changes you want**
- Some files to note in here are
- **server.properties** - properties like server name, game mode, world type etc…
- **ops.json** - list of server operators (easier to set ingame)
- **whitelist.json** - list of players allowed to join the server everyone else rejected access.
9. **Run the container**
- `docker compose up -d` (the -d means detatched so we can run the server in the background)
- `docker logs minecraft-server --follow` Will show us the progress of the server startup (to exit out of this do CTRL+C)
- If you see something like the following then you’re a winner 🥳
```bash
[18:17:01] [Server thread/INFO]: Time elapsed: 25529 ms
[18:17:01] [Server thread/INFO]: Done (34.571s)! For help, type "help"
```
## Conclusion
Well done you have successfully setup a Minecraft server, now go play !!
There is a lot of cool stuff you can do with a Minecraft server for
example installing mods or creating scripts to manage the server, this
will be covered in the next post so keep an eye out for it !!
[^1]: Hosting your own dedicated server allows you to modify every aspect of the server as you see fit. I.E you can modify the server-properties, you can implement a whitelist not to mention being able to add any mods you want
[^2]: Requirements Gathered from here [https://minecraft.fandom.com/wiki/Server/Requirements/Dedicated#Unix\_.28Linux.2C\_BSD.2C\_macOS.29](https://minecraft.fandom.com/wiki/Server/Requirements/Dedicated#Unix_.28Linux.2C_BSD.2C_macOS.29)
[^3]: Yaml is very picky 😞 when it comes to formatting so if you encounter any errors double check your formatting !!
[^4]: I have left Forge out as it is a more involved process plus Fabric is better 😜
[^5]: Right click the green link that says something like minecraft_server.x.xx.x.jar and copy the link address
curl -o server.jar \<link you copied here\>
[^6]: Select the Minecraft version, Fabric Loader Version and the Installer Version of your choice. I tend to go with the latest.
Copy the curl command under CLI download
+2 -2
View File
@@ -36,9 +36,9 @@ http {
# save logs here
access_log /var/log/nginx/access.log compression;
# where the root here
# where's the root dir
root /usr/share/nginx/html;
# what file to server as index
# what file to serve as index
index index.html index.htm;
location / {
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB