• This repository has been archived on 07/Feb/2021
  • Stars
    star
    291
  • Rank 142,563 (Top 3 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

WebServer (MariaDB, PHP-FPM, Nginx) composed from several separate containers linked together

WebServer (MariaDB, PHP-FPM, Nginx) composed from several separate containers linked together

Currently WebServer consists of such images:

  • Data-only container (based on official debian:jessie image)
  • Logrotate container (based on official debian:jessie image)
  • MariaDB (based on official MariaDB image)
  • Nginx (based on official Nginx image)
  • PHP-FPM (based on nazarpc/php:fpm image, which is official image + bunch of frequently used PHP extensions)
  • SSH (based on phusion/baseimage image, contains pre-installed curl, git, mc, wget, php-cli and composer for your convenience)
  • PhpMyAdmin (based on nazarpc/phpmyadmin image, which is official php image with Apache2, where PhpMyAdmin was installed)
  • Ceph (based on upstream ceph/daemon image)
  • Consul (based on official debian:jessie image)
  • HAProxy (based on official haproxy image)
  • Backup container (based on official debian:jessie image)
  • Restore container (based on official debian:jessie image)
  • nazarpc/webserver-apps for ready to use applications that plays nicely with images mentioned above

If you find this project useful, consider supporting its development on patreon.com/nazarpc, this would help me a lot!

How to use

The most convenient way to use all this is Docker Compose

At first you'll need to create persistent data-only container that will store all files, databases, ssh keys and settings of all these things:

docker run --name example.com nazarpc/webserver:data-v1

NOTE: -v1 suffix here and in all other places is optional (there are also images without -v1 suffix and they are exactly the same), however, it is possible that in future images without suffixes become completely incompatible and -v2 suffixed images will be introduced, so you'd better be protected from upgrading to incompatible image rather than getting broken setup at some point in future (this might not happen ever, but still).

This container will start and stop immediately, that is OK.

After this create directory for your website, it will contain docker-compose.yml file and potentially more files you'll need:

mkdir example.com
cd example.com

Now create docker-compose.yml inside with following contents:

version: '2'
services:
  data:
    image: nazarpc/webserver:data-v1
    volumes_from:
      - container:example.com
  
  logrotate:
    image: nazarpc/webserver:logrotate-v1
    restart: always
    volumes_from:
      - data
  
  mariadb:
    image: nazarpc/webserver:mariadb-v1
    restart: always
    volumes_from:
      - data
  
  nginx:
    image: nazarpc/webserver:nginx-v1
    links:
      - php
#    ports:
#      - {ip where to bind}:{port on previous ip where to bind}:80
    restart: always
    volumes_from:
      - data
  
  php:
    image: nazarpc/webserver:php-fpm-v1
    links:
      - mariadb:mysql
    restart: always
    volumes_from:
      - data
  
#  phpmyadmin:
#    image: nazarpc/webserver:phpmyadmin-v1
#    links:
#      - mariadb:mysql
#    restart: always
#    ports:
#      - {ip where to bind}:{port on previous ip where to bind}:80
  
  ssh:
    image: nazarpc/webserver:ssh-v1
    restart: always
    volumes_from:
      - data
#    ports:
#      - {ip where to bind}:{port on previous ip where to bind}:22
#    environment:
#      PUBLIC_KEY: '{your public SSH key}'

Now customize it as you like, feel free to comment-out or remove mariadb, php or ssh container if you have just bunch of static files, also you can uncomment phpmyadmin container if needed.

When you're done with editing:

docker-compose up -d

That is it, you have whole WebServer up and running!

Also you might be interested in advanced examples with load balancing and scaling across cluster.

Upgrade

You can easily upgrade your WebServer to new version of software.

Using Docker Compose upgrade is very simple:

docker-compose pull
docker-compose up -d

All containers will be recreated from new images in few seconds.

Backup/restore images are not present in docker-compose.yml, so if you're using them - pull them manually.

Alternatively you can pull all images manually:

docker pull nazarpc/webserver:data-v1
docker pull nazarpc/webserver:logrotate-v1
docker pull nazarpc/webserver:mariadb-v1
docker pull nazarpc/webserver:nginx-v1
docker pull nazarpc/webserver:php-fpm-v1
docker pull nazarpc/webserver:ssh-v1
docker pull nazarpc/webserver:backup-v1
docker pull nazarpc/webserver:restore-v1

And again in directory with docker-compose.yml:

docker-compose up -d

Backup

To make backup you need to only backup volumes of data-only container. The easiest way to do that is using nazarpc/webserver:backup-v1 image:

docker run --rm --volumes-from=example.com -v /backup-on-host:/backup --env BACKUP_FILENAME=new-backup nazarpc/webserver:backup-v1

This will result in /backup-on-host/new-backup.tar file being created - feel free to specify other directory and other name for backup file.

All other containers are standard and doesn't contain anything important, that is why upgrade process is so simple.

NOTE: You'll likely want to stop MariaDB instance before backup (it is enough to stop master node in case of MariaDB cluster with 2+ nodes)

Restore

Restoration from backup is not more difficult that making backup, there is nazarpc/webserver:restore-v1 image for that:

docker run --rm --volumes-from=example.com -v /backup-on-host/new-backup.tar:/backup.tar nazarpc/webserver:restore-v1

That is it, empty just created example.com container will be filled with data from backup and ready to use.

SSH

SSH might be needed to access files from outside, especially with git.

Before you enter ssh container via SSH for the first time, you need to specify public SSH key (how to generate SSH keys). The easiest way to do this is to define PUBLIC_KEY environment variable in docker-compose.yml. Alternatively you can create file /data/.ssh/authorized_keys and put your public key contents inside. For example, you can do that from Midnight Commander file manager:

docker-compose run ssh mc

When public SSH key is added you should be able to access container as git user:

Internal structure

Internally all that matters is /data directory - it contains all necessary files (or symlinks sometimes) for your convenience - here you can see files for Nginx and MariaDB, their logs and configs, PHP-FPM's config, SSH config and SSH keys directory. That is all what will be persistent, everything else outside /data will be lost during upgrade.

Update configuration

If you update some configuration - you don't need to restart everything, restart only specific service you need, for instance:

docker-compose restart nginx

License

MIT license, see license.txt

More Repositories

1

PickMeUp

Really simple, powerful, customizable and lightweight standalone datepicker
JavaScript
620
star
2

CleverStyle-Framework

CleverStyle Framework is simple, scalable, fast and secure full-stack PHP framework
PHP
150
star
3

noise-c.wasm

rweather/noise-c compiled to WebAssembly using Emscripten and optimized for small size
LiveScript
92
star
4

RTL8814AU

Realtek RTL8814AU USB Wi-Fi driver
C
50
star
5

docker-phpmyadmin

phpMyAdmin as Docker container, based on official image, always latest version
PHP
40
star
6

BananaHTML

BananaHTML - single class that makes HTML generating easier
PHP
39
star
7

solax-local-api-docs

Solax local API docs
38
star
8

webtorrent-dht

This is an example implementation of something that might become WebTorrent DHT
LiveScript
29
star
9

just-backup-btrfs

Script that does just that - creates backups using snapshot of btrfs filesystem. Also it makes rotation of snapshots by removing old ones and keeping as many snapshots as you want.
PHP
27
star
10

blake2.wasm

BLAKE2b and BLAKE2s hash functions compiled to WebAssembly using Emscripten and optimized for small size
LiveScript
27
star
11

spotify-to-vk

Download Spotify music tracks as mp3 through vk.com
PHP
24
star
12

Useful-PHP-Functions

Set of system-independent functions from CleverStyle Framework
PHP
21
star
13

CleverStyle-PhpStorm-theme

Dark theme for PhpStorm
19
star
14

CleverStyle-Music

CleverStyle Music Open Web App. Music player for Firefox OS built using open web technologies.
JavaScript
18
star
15

space-acres

Space Acres is an opinionated unofficial GUI application for farming on Subspace Network
Rust
16
star
16

ronion

Generic anonymous routing protocol framework agnostic to encryption algorithm and transport layer
LiveScript
14
star
17

Flexy-plexy

Ridiculously simple, incredibly powerful grid system
CSS
14
star
18

supercop.wasm

orlp/ed25519 compiled to WebAssembly using Emscripten and optimized for small size
JavaScript
13
star
19

php-markdown-next

PHP Markdown Next parser, based on PHP Markdown Extra and PHP Markdown Extra Extended
PHP
11
star
20

CSTester

IS NOT MAINTAINED ANYMORE, use PHPT tests instead
PHP
9
star
21

vk-photo-saver

Download your photo in vk.com to PC.
Python
9
star
22

stream-slicer

Get slice of any seekable stream
PHP
8
star
23

phpt-tests-runner

Runner for PHPT tests (with few differences comparing to original PHPT format)
PHP
8
star
24

NPW-1.0

Dual SSI EEB motherboards PC case parametrically designed in SolveSpace
HTML
8
star
25

metadata-audio-parser

Library that parse metadata from mp3(ID3v1 and ID3v2 tags)/mp4(aac, m4a, etc.)/ogg audio files
JavaScript
8
star
26

ed25519-to-x25519.wasm

Library for converting Ed25519 signing key pair into X25519/Curve25519 key pair suitable for Diffie-Hellman key exchange
LiveScript
7
star
27

btrfs-sync-subvolumes

This is a pretty naive implementation of replication exact set of subvolumes from one location to another, plays nicely with Just backup btrfs
PHP
7
star
28

docker-php

More feature-complete PHP Docker images based on official images
Shell
7
star
29

es-dht

Generic DHT framework agnostic to command set and transport layer
LiveScript
6
star
30

matx-open-test-bench

Basic test bench for standard Micro ATX motherboard designed for 3D printing without supports
5
star
31

CleverStyle-PhpStorm-codestyle

Codestyle for PhpStorm (PHP, JS, CSS, LESS)
4
star
32

event-listener-primitives

Low-level primitive for building Node.js-like event listeners
Rust
4
star
33

h264-profile-level-id

Rust
3
star
34

side-futures

Send future for execution on the runtime that may be in a different thread
Rust
3
star
35

opir.org

opir.org Source code
PHP
3
star
36

docker-subset-font

Modifies font file to only include characters from specified CSS file
PHP
3
star
37

docker-webserver-apps

Carefully crafted images that are intended to be used with nazarpc/webserver:* family of images
Dockerfile
3
star
38

docker-coturn

Coturn TURN server as Docker image (achived, use official coturn image instead)
Shell
2
star
39

fixed-size-multiplexer

A tiny library for multiplexing data chunks into blocks of fixed size and vice versa
LiveScript
2
star
40

Frontendweekend

CSS
2
star
41

CherryTea.org

This is complete source code of CherryTea.org
PHP
2
star
42

merkle-tree-binary

Set of functions for creating Merkle Tree, proofs and verifying proofs using binary data
TypeScript
2
star
43

css-template-layout

JavaScript (jQuery) implementation of the CSS Template Layout Module
JavaScript
2
star
44

MyBlog

Demo of simple blog module for CleverStyle CMS 0.393 (outdated)
PHP
2
star
45

cherrytea.org-old

PHP
1
star
46

aez.wasm

AEZ cipher compiled to WebAssembly using Emscripten and optimized for small size
LiveScript
1
star
47

unicode-range-splitter

Unicode range splitter for icon fonts
PHP
1
star
48

async-eventer

A tiny library with asynchronous Promise-based implementation of events dispatching and handling
LiveScript
1
star
49

array-map-set

Just like regular Map and Set, but treats different ArrayBufferView's with the same values as equal
LiveScript
1
star
50

registry-demo-chain

Rust
1
star