Merge pull request #3 from NamelessMC/v2

V2
This commit is contained in:
Robin 2020-08-21 16:52:36 +02:00 committed by GitHub
commit 7e75ca3cd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 167 additions and 105 deletions

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2017 Birkhoff Lee Copyright (c) 2020 NamelessMC Docker Image Maintainers (https://github.com/NamelessMC/Nameless-Docker/graphs/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,76 +1,28 @@
# NamelessMC Docker [![](https://images.microbadger.com/badges/image/birkhofflee/namelessmc-docker.svg)](https://microbadger.com/images/birkhofflee/namelessmc-docker) # NamelessMC Docker
This is the official Docker image for NamelessMC. Deploy with ease! This is the official Docker image for NamelessMC. Deploy with ease!
# Usage ## Usage
## # Install Docker ### Install Docker
Obviously, if you wanna use Docker for deployment, you need to install Docker.
You have to manually install Docker first if you don't have it installed on your server. Check out the official install guide here: https://docs.docker.com/engine/installation. You have to manually install Docker first if you don't have it installed on your server. Check out the [official install guide](https://docs.docker.com/engine/installation).
If you want to specify the version of NamelessMC you want, head to https://github.com/NamelessMC/Nameless-Docker#manually-run-commands. ### Automated Deployment
## # Automated Deployment You will need to install [Docker Compose](https://docs.docker.com/compose/) for automated deploying.
You will need to install [Docker Compose](https://docs.docker.com/compose/) for automated deploying. If you don't have it installed, run the following:
```bash ```bash
$ curl -L "https://github.com/docker/compose/releases/download/1.11.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo apt install docker-compose
$ chmod +x /usr/local/bin/docker-compose
``` ```
> If you got a “Permission denied” error while running the commands above, add `sudo` at the beginning of each of them and run again. This will require sudo access. Download [docker-compose.yml](https://github.com/NamelessMC/Nameless-Docker/raw/master/docker-compose.yml), optionally change some settings, then run `docker-compose up -d`. The default restart policy is `unless-stopped` so your website will start back up after a reboot.
When you're done, clone this repository and run! (`-d` means detach mode, e.g. run in background) When the containers are up, visit the website in a browser to start the installer. By default it listens on any interface, port 80.
```bash When the database configuration page shows up, fill in `db` for *database address*. For database username, password and database name, fill `nameless` for all of them, if you used default database credentials.
$ git clone https://github.com/NamelessMC/Nameless-Docker
$ cd NamelessMC-docker
$ docker-compose up -d
```
When the container is up, follow the guide at https://github.com/NamelessMC/Nameless-Docker#namelessmc-installation.
## # Manual Deployment ## Development
If you more like to run the containers by yourself or using them with other containers like [jwilder/nginx-proxy](https://github.com/jwilder/nginx-proxy), you may want to do it yourself.
First, clone the repository: If you want to use Docker for developing NamelessMC, please see the [docker compose file in the main repo](https://github.com/NamelessMC/Nameless/blob/v2/docker-compose.yaml).
```bash
$ git clone https://github.com/NamelessMC/Nameless-Docker
$ cd Nameless-Docker
```
Next, build the image.
```bash
$ docker build -t namelessmc .
```
If you want to specify the version:
```bash
$ docker build --build-arg NAMELESSMC_VERSION=1.0.21 -t namelessmc .
```
The version number **MUST BE** listed [here](https://github.com/NamelessMC/Nameless/releases) and it's **not guranteed** to work.
Next, run the image we just built and a MySQL container as well.
```bash
$ docker run -d -e "MYSQL_ROOT_PASSWORD=nameless" -e "MYSQL_USER=nameless" -e "MYSQL_PASSWORD=nameless" -e "MYSQL_DATABASE=nameless" --name nameless_db mysql
$ docker run -d -p 80:80 --link nameless_db --name nameless namelessmc
```
That's it!
# Installation
After deploying the containers, open up the corresponding URL in your web browser to get started with NamelessMC.
By default, the web server will be available at `0.0.0.0:80`, means if you deployed it on you own computer, the URL is gonna be `http://localhost`. Instead, if you did it on a remote server, the URL would be `http://<your-server-ip-addr>`.
Follow the install instructions. When the database configuration page shows up, fill in `db` for the *database address*. For database username, password and database name, fill `nameless` for all of them, if you used default database credentials.
When you're done, submit and follow the rest of installation.
# About
This repository was moved from [Birkhoff Lee](https://github.com/BirkhoffLee), and the original repository is here: https://github.com/BirkhoffLee/namelessmc-docker, carefully made in Taiwan. :heart:

11
deploy.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
set -e
docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
export DOCKER_CLI_EXPERIMENTAL=enabled
set +e
docker buildx rm namelessmc_builder
set -e
docker buildx create --use --name namelessmc_builder
docker buildx build -t namelessmc/nginx --platform=linux/arm,linux/arm64,linux/amd64 nginx_web --push
docker buildx build -t namelessmc/php --platform=linux/arm,linux/arm64,linux/amd64 php_fpm --push
docker buildx rm namelessmc_builder

View File

@ -1,23 +1,27 @@
version: '3.1' version: '2'
services: services:
nameless: nginx:
build: image: namelessmc/nginx
context: src ports: ['80:80']
volumes: ['/srv/namelessmc/web:/data'] # same as php container
# environment:
# PHP_FPM: php:9000
depends_on: [php]
restart: unless-stopped
php:
image: namelessmc/php
volumes: ['/srv/namelessmc/web:/data'] # same as web container
restart: unless-stopped restart: unless-stopped
links:
- db
ports:
- "80:80"
db: db:
image: mysql:5.7 image: mariadb
restart: unless-stopped volumes: ['/srv/namelessmc/db:/var/lib/mysql']
expose:
- 3306
environment: environment:
- "MYSQL_ROOT_PASSWORD=nameless" MYSQL_ROOT_PASSWORD: nameless
- "MYSQL_USER=nameless" MYSQL_USER: nameless
- "MYSQL_PASSWORD=nameless" MYSQL_PASSWORD: nameless
- "MYSQL_DATABASE=nameless" MYSQL_DATABASE: nameless
restart: unless-stopped

15
nginx_web/Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM nginx:alpine
ENV PHP_FPM="php:9000"
RUN deluser xfs && \
delgroup www-data && \
adduser -DH -h /home/www-data -s /sbin/nologin -u 33 www-data
RUN find /etc/nginx -type f -not -name 'mime.types' -not -name 'fastcgi_params' -delete && \
rm -rf conf.d modules
COPY nginx.conf /etc/nginx
COPY entrypoint.sh /
ENTRYPOINT [ "sh", "/entrypoint.sh" ]

9
nginx_web/entrypoint.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/sh
cat > /etc/nginx/php.conf << EOL
upstream php-handler {
server ${PHP_FPM};
}
EOL
exec nginx -g "daemon off;"

55
nginx_web/nginx.conf Normal file
View File

@ -0,0 +1,55 @@
user "www-data";
events {
worker_connections 1024;
}
http {
access_log /dev/stdout;
error_log /dev/stdout;
include mime.types;
default_type application/octet-stream;
include php.conf;
server {
listen 80 default_server;
server_name _;
index index.php index.html;
proxy_read_timeout 3600;
fastcgi_read_timeout 3600;
# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;
root /data;
location / {
try_files $uri $uri/ /index.php?route=$uri&$args;
}
location ~ \.(tpl|cache)$ {
return 403;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-handler;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
client_max_body_size 0;
}
}

21
php_fpm/Dockerfile Normal file
View File

@ -0,0 +1,21 @@
FROM php:7.4-fpm
ARG NAMELESSMC_VERSION=2.0.0-pr7
RUN docker-php-source extract && \
BUILD_DEPS="libmcrypt-dev libldap2-dev libjpeg62-turbo-dev libfreetype6-dev" && \
apt-get update && \
apt-get install -y $BUILD_DEPS libpng-dev curl tar && \
docker-php-ext-configure gd && \
docker-php-ext-install -j "$(nproc)" exif gd pdo_mysql mysqli && \
docker-php-source delete && \
apt-get purge -y $BUILD_DEPS && \
apt-get clean && \
apt-get autoremove --purge -y && \
rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/* /var/tmp/*
ADD entrypoint.sh /
ENV NAMELESSMC_VERSION=2.0.0-pr7
ENTRYPOINT [ "bash", "/entrypoint.sh" ]

22
php_fpm/entrypoint.sh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/bash
set -e
if [ -n "$(ls -A /data 2>/dev/null)" ]
then
echo "Data directory contains files, not downloading NamelessMC"
else
echo "Data directory is empty, downloading NamelessMC.."
set -x
mkdir -p /data
cd /tmp
curl -Lo nameless.tar.gz https://github.com/NamelessMC/Nameless/archive/v$NAMELESSMC_VERSION.tar.gz
tar -xf nameless.tar.gz
mv Nameless-$NAMELESSMC_VERSION/{,.[^.]}* /data
chown -R www-data:www-data /data
chmod 755 -R /data
rm -rf /tmp
set +x
echo "Done!"
fi
exec php-fpm

View File

@ -1,27 +0,0 @@
FROM php:7.0-apache
ARG NAMELESSMC_VERSION=1.0.21
WORKDIR /var/www
RUN docker-php-source extract \
&& apt-get update \
&& apt-get install -y libmcrypt-dev libldap2-dev libpng-dev libjpeg62-turbo-dev libfreetype6-dev curl tar \
&& docker-php-ext-install pdo pdo_mysql mysqli \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& a2enmod rewrite \
&& docker-php-source delete
RUN curl -Lo nameless.tar.gz https://github.com/NamelessMC/Nameless/archive/v$NAMELESSMC_VERSION.tar.gz \
&& tar -xvf nameless.tar.gz \
&& mv Nameless-$NAMELESSMC_VERSION/* /var/www/html/ \
&& bash -c "mv Nameless-$NAMELESSMC_VERSION/.[^.]* /var/www/html/" \
&& rm -rf nameless.tar.gz Nameless-$NAMELESSMC_VERSION \
&& chown -R www-data:www-data /var/www/html \
&& chmod 755 -R /var/www/html
RUN apt-get clean \
&& apt-get autoclean \
&& apt-get autoremove --purge -y \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/* /var/tmp/*