Skip to content

Commit e0ba996

Browse files
author
Milan Kotykov
committed
add Dockerfile, docker-compose file, update README.md with instructions on running in docker
1 parent b6bc3ff commit e0ba996

5 files changed

Lines changed: 67 additions & 0 deletions

File tree

‎.dockerignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.dockerignore
2+
.git
3+
.gitignore
4+
docker/*
5+
*.md

‎README.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,20 @@ IT DIFFERS IN MANY RESPECTS FROM THE OFFICIAL LWT-VERSION
2929
* Two database backup modes (new or old structure)
3030

3131

32+
# Install instructions
33+
## Run in [Docker](https://docs.docker.com/get-docker/)
34+
This repository contains docker-compose file to accomodate running LWT in a docker container.
35+
#### To use it, change into project root folder and run
3236

37+
docker-compose -f docker/docker-compose.yml up -d
38+
39+
#### By default the server can be accessed on port 8010
40+
http://localhost:8010
41+
42+
To remove the created containers run
43+
44+
docker-compose -f docker/docker-compose.yml down
45+
3346
---
3447
## Original README from LWT
3548

‎docker/.env‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DB_HOSTNAME=mariadb
2+
DB_USER=root
3+
DB_PASSWORD=secret
4+
DB_DATABASE=learning_with_texts

‎docker/Dockerfile‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM php:7.4-apache-buster
2+
3+
# creating config file php.ini
4+
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \
5+
echo 'mysqli.allow_local_infile = On' >> "$PHP_INI_DIR/php.ini"
6+
7+
RUN docker-php-ext-install pdo pdo_mysql mysqli
8+
9+
COPY . /var/www/html/
10+
11+
# creating connect.inc.php
12+
ARG DB_HOSTNAME
13+
ARG DB_USER
14+
ARG DB_PASSWORD
15+
ARG DB_DATABASE
16+
RUN printf '<?php\n$server = "%s";\n$userid = "%s";\n$passwd = "%s";\n$dbname = "%s";\n?>' "$DB_HOSTNAME" "$DB_USER" "$DB_PASSWORD" "$DB_DATABASE" > /var/www/html/connect.inc.php

‎docker/docker-compose.yml‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: "3.9"
2+
services:
3+
web:
4+
build:
5+
context: ./..
6+
dockerfile: docker/Dockerfile
7+
args:
8+
- DB_HOSTNAME
9+
- DB_USER
10+
- DB_PASSWORD
11+
- DB_DATABASE
12+
container_name: lwt
13+
depends_on:
14+
- db
15+
ports:
16+
- "8010:80"
17+
restart: unless-stopped
18+
db:
19+
container_name: lwt_db
20+
environment:
21+
MYSQL_ALLOW_EMPTY_PASSWORD: "no"
22+
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
23+
hostname: ${DB_HOSTNAME}
24+
image: mariadb:10.5
25+
restart: unless-stopped
26+
volumes:
27+
- lwt_db_data:/var/lib/mysql
28+
volumes:
29+
lwt_db_data:

0 commit comments

Comments
 (0)