Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
migasQ committed Jun 2, 2023
0 parents commit afe89cb
Show file tree
Hide file tree
Showing 24,946 changed files with 4,895,278 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
8 changes: 8 additions & 0 deletions .env-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
HOSTING_EMAIL=
MOODLE_DATA=./moodledata
MOODLE_URL=localhost
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=moodle
MYSQL_USER=moodle
MYSQL_PASSWORD=moodle
MYSQL_DATA=./dbdata
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vscode
moodledata
dbdata
www/config.php
.env
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Moodle

## Start

- `cp .env-template .env` and edit accordingly
- `cp www/config-template.php www/config.php` and edit accordingly
- `docker-compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g)`
- `docker compose up -d`

## Update

- `docker-compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g)`
- `docker compose up -d`
87 changes: 87 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
version: "3"

services:
nginx:
build: ./nginx
container_name: nginx
restart: always
volumes:
- ./www:/var/www/html
- ${MOODLE_DATA}:/var/www/moodledata
labels:
- traefik.enable=true
- traefik.http.routers.moodle-http.rule=Host(`${MOODLE_URL}`)
- traefik.http.routers.moodle-http.entrypoints=http
- traefik.http.routers.moodle-http.middlewares=https-redirect
- traefik.http.routers.moodle-https.rule=Host(`${MOODLE_URL}`)
- traefik.http.routers.moodle-https.entrypoints=https
- traefik.http.routers.moodle-https.tls=true
- traefik.http.routers.moodle-https.tls.certresolver=le
- traefik.http.services.moodle.loadbalancer.server.port=8080
logging:
driver: local
options:
max-size: "20m"
max-file: "5"

php-fpm:
build: ./php
container_name: php-fpm
restart: always
volumes:
- ./www:/var/www/html
- ${MOODLE_DATA}:/var/www/moodledata
logging:
driver: local
options:
max-size: "20m"
max-file: "5"

db:
image: mysql:8.0
container_name: db
hostname: db
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
environment:
- MYSQL_ROOT_PASSWORD
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
restart: always
volumes:
- ${MYSQL_DATA}:/var/lib/mysql

traefik:
image: traefik:2.8
container_name: traefik
ports:
- 80:80
- 443:443
labels:
- traefik.http.middlewares.https-redirect.redirectscheme.scheme=https
- traefik.http.middlewares.https-redirect.redirectscheme.permanent=true
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- traefik-public-certificates:/certificates
command:
- --providers.docker
- --providers.docker.exposedbydefault=false
- --entrypoints.http.address=:80
- --entrypoints.https.address=:443
- --certificatesresolvers.le.acme.email=$HOSTING_EMAIL
- --certificatesresolvers.le.acme.storage=/certificates/acme.json
- --certificatesresolvers.le.acme.tlschallenge=true
- --log
- --log.level=ERROR
restart: always
logging:
driver: local
options:
max-size: "20m"
max-file: "5"

volumes:
traefik-public-certificates:
7 changes: 7 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM nginx:latest

ARG UID=1000
ARG GID=1000
RUN usermod -u $UID -o nginx && groupmod -g $GID -o nginx

COPY default.conf /etc/nginx/conf.d/default.conf
42 changes: 42 additions & 0 deletions nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
server {
listen 8080;
server_name _;

index index.php index.html index.htm;
root /var/www/html;

server_tokens off;

gzip on;
gzip_types text/plain text/xml text/css image/svg+xml application/javascript application/x-javascript application/json application/xml;

client_max_body_size 500M;

location / {
try_files $uri $uri/ =404;
}

location ~ /\.(?!well-known).* {
return 404;
}

location /dataroot/ {
internal;
alias /var/www/moodledata/;
}

location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass php-fpm:9000;
include fastcgi_params;
fastcgi_read_timeout 180;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~ (/vendor/|/node_modules/|composer\.json|/readme|/README|readme\.txt|/upgrade\.txt|db/install\.xml|/fixtures/|/behat/|phpunit\.xml|\.lock|environment\.xml) {
deny all;
return 404;
}
}
23 changes: 23 additions & 0 deletions php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM php:8.1-fpm

ARG UID=1000
ARG GID=1000
RUN usermod -u $UID -o www-data && groupmod -g $GID -o www-data

COPY php.ini $PHP_INI_DIR/php.ini

RUN apt-get update && apt-get install -y \
libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
libicu-dev \
zip libzip-dev \
libxml2-dev && \
docker-php-ext-configure \
gd --with-freetype --with-jpeg && \
docker-php-ext-install -j$(nproc) \
gd \
intl \
zip \
mysqli \
soap \
opcache \
exif
Loading

0 comments on commit afe89cb

Please sign in to comment.