Skip to content

Commit 83f0ea4

Browse files
committedMay 11, 2022
rebuild
1 parent 27c8884 commit 83f0ea4

10 files changed

+151
-149
lines changed
 

‎Dockerfile

+24-60
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,43 @@
1-
FROM ubuntu:16.04
2-
MAINTAINER Fer Uria <fauria@gmail.com>
3-
LABEL Description="Cutting-edge LAMP stack, based on Ubuntu 16.04 LTS. Includes .htaccess support and popular PHP7 features, including composer and mail() function." \
1+
FROM debian:stable-slim
2+
MAINTAINER alex00111111 <alex00111111@protonmail.com>
3+
LABEL Description="LAMP stack, based on latest debian-slim. Includes .htaccess support, MariaDB and PHP7." \
44
License="Apache License 2.0" \
5-
Usage="docker run -d -p [HOST WWW PORT NUMBER]:80 -p [HOST DB PORT NUMBER]:3306 -v [HOST WWW DOCUMENT ROOT]:/var/www/html -v [HOST DB DOCUMENT ROOT]:/var/lib/mysql fauria/lamp" \
5+
Usage="docker run -d -p [HOST WWW PORT NUMBER]:80 docker-lamp" \
66
Version="1.0"
77

8-
RUN apt-get update
9-
RUN apt-get upgrade -y
10-
11-
COPY debconf.selections /tmp/
12-
RUN debconf-set-selections /tmp/debconf.selections
13-
14-
RUN apt-get install -y zip unzip
15-
RUN apt-get install -y \
16-
php7.0 \
17-
php7.0-bz2 \
18-
php7.0-cgi \
19-
php7.0-cli \
20-
php7.0-common \
21-
php7.0-curl \
22-
php7.0-dev \
23-
php7.0-enchant \
24-
php7.0-fpm \
25-
php7.0-gd \
26-
php7.0-gmp \
27-
php7.0-imap \
28-
php7.0-interbase \
29-
php7.0-intl \
30-
php7.0-json \
31-
php7.0-ldap \
32-
php7.0-mbstring \
33-
php7.0-mcrypt \
34-
php7.0-mysql \
35-
php7.0-odbc \
36-
php7.0-opcache \
37-
php7.0-pgsql \
38-
php7.0-phpdbg \
39-
php7.0-pspell \
40-
php7.0-readline \
41-
php7.0-recode \
42-
php7.0-snmp \
43-
php7.0-sqlite3 \
44-
php7.0-sybase \
45-
php7.0-tidy \
46-
php7.0-xmlrpc \
47-
php7.0-xsl \
48-
php7.0-zip
49-
RUN apt-get install apache2 libapache2-mod-php7.0 -y
50-
RUN apt-get install mariadb-common mariadb-server mariadb-client -y
51-
RUN apt-get install postfix -y
52-
RUN apt-get install git nodejs npm composer nano tree vim curl ftp -y
53-
RUN npm install -g bower grunt-cli gulp
8+
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
9+
php \
10+
php-mysql \
11+
apache2 \
12+
libapache2-mod-php \
13+
mariadb-server \
14+
git
5415

16+
RUN rm -rf /var/lib/apt/lists/*
5517
ENV LOG_STDOUT **Boolean**
5618
ENV LOG_STDERR **Boolean**
5719
ENV LOG_LEVEL warn
5820
ENV ALLOW_OVERRIDE All
5921
ENV DATE_TIMEZONE UTC
6022
ENV TERM dumb
23+
ENV DATABASE "testdb"
24+
ENV DATABASE_CHARSET "utf8"
25+
ENV DATABASE_USER "reader"
26+
ENV DATABASE_PW "testtest"
27+
ENV GITREPO "https://github.com/banago/simple-php-website"
6128

62-
COPY index.php /var/www/html/
29+
#only for testing, can be removed
30+
COPY www/* /var/www/html/
31+
32+
#startup-script
6333
COPY run-lamp.sh /usr/sbin/
34+
#sql-file for DB-import
35+
COPY setup.sql /opt/
6436

6537
RUN a2enmod rewrite
66-
RUN ln -s /usr/bin/nodejs /usr/bin/node
6738
RUN chmod +x /usr/sbin/run-lamp.sh
6839
RUN chown -R www-data:www-data /var/www/html
6940

70-
VOLUME /var/www/html
71-
VOLUME /var/log/httpd
72-
VOLUME /var/lib/mysql
73-
VOLUME /var/log/mysql
74-
VOLUME /etc/apache2
75-
76-
EXPOSE 80
77-
EXPOSE 3306
41+
EXPOSE 8080
7842

7943
CMD ["/usr/sbin/run-lamp.sh"]

‎LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Fer Uría
3+
Copyright (c) 2022
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎README.md

+67-80
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,47 @@
1-
fauria/lamp
1+
alex00111111/docker-lamp
22
==========
33

4-
![docker_logo](https://raw.githubusercontent.com/fauria/docker-lamp/master/docker_139x115.png)![docker_fauria_logo](https://raw.githubusercontent.com/fauria/docker-lamp/master/docker_fauria_161x115.png)
4+
This Project is forked and inspired from [fauria/lamp](https://github.com/fauria/docker-lamp/).
55

6-
[![Docker Pulls](https://img.shields.io/docker/pulls/fauria/lamp.svg?style=plastic)](https://hub.docker.com/r/fauria/lamp/)
7-
[![Docker Build Status](https://img.shields.io/docker/build/fauria/lamp.svg?style=plastic)](https://hub.docker.com/r/fauria/lamp/builds/)
8-
[![](https://images.microbadger.com/badges/image/fauria/lamp.svg)](https://microbadger.com/images/fauria/lamp "fauria/lamp")
6+
Main Goal is to build a LAMP-stack for simple semi-dynamic Websites as a monolithic Container.
7+
8+
The Container is static, Database/Filesystem changes on Runtime will be lost on restart.
9+
10+
11+
Just replace the setup.sql with your datafile and set the link to your WebProject-git (Dockerfile: ENV GITREPO). Customize DB Credentials and Database settings at Dockerfile ENVs ( DATABASE, DATABASE_USER, DATABASE_PW ).
912

10-
This Docker container implements a last generation LAMP stack with a set of popular PHP modules. Includes support for [Composer](https://getcomposer.org/), [Bower](http://bower.io/) and [npm](https://www.npmjs.com/) package managers and a Postfix service to allow sending emails through PHP [mail()](http://php.net/manual/en/function.mail.php) function.
1113

12-
If you dont need support for MySQL/MariaDB, or your app runs on PHP 5.4, maybe [fauria/lap](https://hub.docker.com/r/fauria/lap) suits your needs better.
1314

1415
Includes the following components:
1516

16-
* Ubuntu 16.04 LTS Xenial Xerus base image.
17+
* Debian slim latest
1718
* Apache HTTP Server 2.4
18-
* MariaDB 10.0
19-
* Postfix 2.11
20-
* PHP 7
21-
* PHP modules
22-
* php-bz2
23-
* php-cgi
24-
* php-cli
25-
* php-common
26-
* php-curl
27-
* php-dbg
28-
* php-dev
29-
* php-enchant
30-
* php-fpm
31-
* php-gd
32-
* php-gmp
33-
* php-imap
34-
* php-interbase
35-
* php-intl
36-
* php-json
37-
* php-ldap
38-
* php-mcrypt
39-
* php-mysql
40-
* php-odbc
41-
* php-opcache
42-
* php-pgsql
43-
* php-phpdbg
44-
* php-pspell
45-
* php-readline
46-
* php-recode
47-
* php-snmp
48-
* php-sqlite3
49-
* php-sybase
50-
* php-tidy
51-
* php-xmlrpc
52-
* php-xsl
53-
* Development tools
54-
* git
55-
* composer
56-
* npm / nodejs
57-
* bower
58-
* vim
59-
* tree
60-
* nano
61-
* ftp
62-
* curl
63-
64-
Installation from [Docker registry hub](https://registry.hub.docker.com/r/fauria/lamp/).
19+
* MariaDB 10.x
20+
* PHP 7.4
21+
* git
22+
23+
24+
Usage
6525
----
6626

67-
You can download the image using the following command:
6827

6928
```bash
70-
docker pull fauria/lamp
29+
# build
30+
docker build -t docker-lamp . --no-cache=true
31+
32+
# run
33+
docker run -d -p 8080:80 docker-lamp
34+
35+
# phpinfo
36+
curl "http://$(docker-machine ip):8080/info.php"
37+
38+
# example Sql-Connection
39+
curl "http://$(docker-machine ip):8080/dbexample.php"
40+
41+
# example PHP-Project
42+
curl "http://$(docker-machine ip):8080/"
7143
```
7244

73-
Environment variables
74-
----
7545

7646
This image uses environment variables to allow the configuration of some parameteres at run time:
7747

@@ -116,18 +86,46 @@ This image uses environment variables to allow the configuration of some paramet
11686
* Accepted values: dumb
11787
* Description: Allow usage of terminal programs inside the container, such as `mysql` or `nano`.
11888

119-
Exposed port and volumes
12089
----
12190

122-
The image exposes ports `80` and `3306`, and exports four volumes:
91+
* Variable name: DATABASE
92+
* Default value: testdb
93+
* Accepted values: any string which is a valid MariaDB Database name
94+
* Description: set the Database which will be created and where the data from the setup.sql are imported.
95+
96+
----
97+
98+
* Variable name: DATABASE_CHARSET
99+
* Default value: utf8
100+
* Accepted values: any supported character set [supported character sets](https://mariadb.com/kb/en/supported-character-sets-and-collations/)
101+
* Description: set the default character set for the given Database.
102+
103+
----
123104

124-
* `/var/log/httpd`, containing Apache log files.
125-
* `/var/log/mysql` containing MariaDB log files.
126-
* `/var/www/html`, used as Apache's [DocumentRoot directory](http://httpd.apache.org/docs/2.4/en/mod/core.html#documentroot).
127-
* `/var/lib/mysql`, where MariaDB data files are stored.
128-
* `/etc/apache2`, where Apache configuration files are stored.
105+
* Variable name: DATABASE_USER
106+
* Default value: reader
107+
* Accepted values: any string which is a valid MariaDB Username
108+
* Description: set the Username which your PHP files are use for retriving data from MariaDB.
129109

130-
Please, refer to https://docs.docker.com/storage/volumes for more information on using host volumes.
110+
----
111+
112+
* Variable name: DATABASE_PW
113+
* Default value: testtest
114+
* Accepted values: any string which is a valid MariaDB password
115+
* Description: set the password which your PHP files use for retriving data from MariaDB
116+
117+
----
118+
119+
* Variable name: GITREPO
120+
* Default value: https://github.com/banago/simple-php-website
121+
* Accepted values: any reachable GIT-Repository via HTTP
122+
* Description: Link to GIT-Repository which will be deployed at /var/www/html/
123+
124+
125+
Exposed port
126+
----
127+
128+
The image exposes ports `80`:
131129

132130
The user and group owner id for the DocumentRoot directory `/var/www/html` are both 33 (`uid=33(www-data) gid=33(www-data) groups=33(www-data)`).
133131

@@ -136,27 +134,16 @@ The user and group owner id for the MariaDB directory `/var/log/mysql` are 105 a
136134
Use cases
137135
----
138136

139-
#### Create a temporary container for testing purposes:
140-
141-
```
142-
docker run -i -t --rm fauria/lamp bash
143-
```
144137

145138
#### Create a temporary container to debug a web app:
146139

147140
```
148-
docker run --rm -p 8080:80 -e LOG_STDOUT=true -e LOG_STDERR=true -e LOG_LEVEL=debug -v /my/data/directory:/var/www/html fauria/lamp
149-
```
150-
151-
#### Create a container linking to another [MySQL container](https://registry.hub.docker.com/_/mysql/):
152-
153-
```
154-
docker run -d --link my-mysql-container:mysql -p 8080:80 -v /my/data/directory:/var/www/html -v /my/logs/directory:/var/log/httpd --name my-lamp-container fauria/lamp
141+
docker run --rm -p 8080:80 -e LOG_STDOUT=true -e LOG_STDERR=true -e LOG_LEVEL=debug docker-lamp
155142
```
156143

157144
#### Get inside a running container and open a MariaDB console:
158145

159146
```
160-
docker exec -i -t my-lamp-container bash
147+
docker exec -i -t docker-lamp bash
161148
mysql -u root
162149
```

‎debconf.selections

-2
This file was deleted.

‎docker_139x115.png

-15.7 KB
Binary file not shown.

‎docker_fauria_161x115.png

-11.6 KB
Binary file not shown.

‎run-lamp.sh

+27-6
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ if [ $LOG_LEVEL != 'warn' ]; then
2525
/bin/sed -i "s/LogLevel\ warn/LogLevel\ ${LOG_LEVEL}/g" /etc/apache2/apache2.conf
2626
fi
2727

28-
# enable php short tags:
29-
/bin/sed -i "s/short_open_tag\ \=\ Off/short_open_tag\ \=\ On/g" /etc/php/7.0/apache2/php.ini
28+
#remove index.html
29+
rm /var/www/html/index.html
3030

3131
# stdout server info:
3232
if [ ! $LOG_STDOUT ]; then
@@ -46,21 +46,42 @@ cat << EOB
4646
· Log Level [LOG_LEVEL]: $LOG_LEVEL
4747
· Allow override [ALLOW_OVERRIDE]: $ALLOW_OVERRIDE
4848
· PHP date timezone [DATE_TIMEZONE]: $DATE_TIMEZONE
49+
· MariaDB Database: $DATABASE
50+
· MariaDB Database Default Character Set: $DATABASE_CHARSET
51+
· MariaDB user: $DATABASE_USER
52+
· MariaDB pw: $DATABASE_PW
53+
· WebProject Git Url: $GITREPO
54+
4955
5056
EOB
5157
else
5258
/bin/ln -sf /dev/stdout /var/log/apache2/access.log
5359
fi
5460

5561
# Set PHP timezone
56-
/bin/sed -i "s/\;date\.timezone\ \=/date\.timezone\ \=\ ${DATE_TIMEZONE}/" /etc/php/7.0/apache2/php.ini
57-
58-
# Run Postfix
59-
/usr/sbin/postfix start
62+
/bin/sed -i "s/\;date\.timezone\ \=/date\.timezone\ \=\ ${DATE_TIMEZONE}/" /etc/php/7.4/apache2/php.ini
6063

64+
#clone your webproject and move it to /var/www/html/
65+
mkdir /opt/tmp/
66+
git clone ${GITREPO} /opt/tmp/
67+
cp /opt/tmp/* /var/www/html/
68+
rm /var/www/html/README.md
69+
rm -r /var/www/html/.git/
70+
rm /var/www/html/.gitignore
71+
rm readme.md
72+
rm -r /opt/tmp
6173
# Run MariaDB
6274
/usr/bin/mysqld_safe --timezone=${DATE_TIMEZONE}&
6375

76+
#mariadb create db and user, import data
77+
sleep 5
78+
mysql -uroot -e "CREATE DATABASE ${DATABASE} /*\!40100 DEFAULT CHARACTER SET ${DATABASE_CHARSET} */;"
79+
mysql -uroot ${DATABASE} < /opt/setup.sql
80+
mysql -uroot -e 'CREATE USER '${DATABASE_USER}'@localhost IDENTIFIED BY "'${DATABASE_PW}'";'
81+
mysql -uroot -e "GRANT SELECT on ${DATABASE}.* to ${DATABASE_USER}@localhost;"
82+
mysql -uroot -e "FLUSH PRIVILEGES;"
83+
rm /opt/setup.sql
84+
6485
# Run Apache:
6586
if [ $LOG_LEVEL == 'debug' ]; then
6687
/usr/sbin/apachectl -DFOREGROUND -k start -e debug

‎setup.sql

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
DROP TABLE IF EXISTS `test`;
2+
3+
CREATE TABLE `test` (
4+
`name` varchar(100) DEFAULT NULL,
5+
`prename` varchar(50) DEFAULT NULL
6+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7+
8+
LOCK TABLES `test` WRITE;
9+
INSERT INTO `test` VALUES ('Payton','Gary'),('Kemp','Shawn'),('McMillan','Nate'),('Perkins','Sam'),('Schrempf','Detlef');
10+
UNLOCK TABLES;
11+

‎www/dbexample.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<html>
2+
3+
4+
<?php
5+
$user = "reader";
6+
$pass = "testtest";
7+
8+
$dbh = new PDO('mysql:host=localhost;dbname=testdb', $user, $pass);
9+
$sth = $dbh->query('SELECT * FROM test');
10+
11+
$rows = $sth->fetchAll();
12+
13+
echo('<table style="border: solid 1px black;"><tr><th>name</th><th>prename</th></tr>');
14+
foreach($rows as $row) {
15+
echo("<tr class='row'><td>$row[0] </td><td> $row[1] </td> </tr>");
16+
17+
}
18+
echo "</table>";
19+
20+
?>
21+
</html>

‎index.php ‎www/info.php

File renamed without changes.

0 commit comments

Comments
 (0)
Please sign in to comment.