Skip to content

Commit c3a58f7

Browse files
committed
Initial Dockerfile and tests
1 parent 1b77789 commit c3a58f7

11 files changed

+526
-5
lines changed

Dockerfile

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# "ported" by Adam Miller <[email protected]> from
2+
# https://github.com/fedora-cloud/Fedora-Dockerfiles
3+
#
4+
# Originally written for Fedora-Dockerfiles by
5+
# scollier <[email protected]>
6+
7+
FROM centos:centos7
8+
MAINTAINER The CentOS Project <[email protected]>
9+
10+
RUN yum -y update; yum clean all
11+
RUN yum -y install epel-release; yum clean all
12+
RUN yum -y install httpd php php-mysql php-gd pwgen supervisor bash-completion openssh-server psmisc tar; yum clean all
13+
ADD ./start.sh /start.sh
14+
ADD ./foreground.sh /etc/apache2/foreground.sh
15+
ADD ./supervisord.conf /etc/supervisord.conf
16+
RUN echo %sudo ALL=NOPASSWD: ALL >> /etc/sudoers
17+
ADD http://wordpress.org/latest.tar.gz /wordpress.tar.gz
18+
RUN tar xvzf /wordpress.tar.gz
19+
RUN mv /wordpress/* /var/www/html/.
20+
RUN chown -R apache:apache /var/www/
21+
RUN chmod 755 /start.sh
22+
RUN chmod 755 /etc/apache2/foreground.sh
23+
RUN mkdir /var/run/sshd
24+
25+
EXPOSE 80
26+
EXPOSE 22
27+
28+
CMD ["/bin/bash", "/start.sh"]

LICENSE

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GNU GENERAL PUBLIC LICENSE
22
Version 2, June 1991
33

4-
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
4+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
55
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
66
Everyone is permitted to copy and distribute verbatim copies
77
of this license document, but changing it is not allowed.
@@ -290,8 +290,8 @@ to attach them to the start of each source file to most effectively
290290
convey the exclusion of warranty; and each file should have at least
291291
the "copyright" line and a pointer to where the full notice is found.
292292

293-
{description}
294-
Copyright (C) {year} {fullname}
293+
<one line to give the program's name and a brief idea of what it does.>
294+
Copyright (C) <year> <name of author>
295295

296296
This program is free software; you can redistribute it and/or modify
297297
it under the terms of the GNU General Public License as published by
@@ -329,12 +329,11 @@ necessary. Here is a sample; alter the names:
329329
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330330
`Gnomovision' (which makes passes at compilers) written by James Hacker.
331331

332-
{signature of Ty Coon}, 1 April 1989
332+
<signature of Ty Coon>, 1 April 1989
333333
Ty Coon, President of Vice
334334

335335
This General Public License does not permit incorporating your program into
336336
proprietary programs. If your program is a subroutine library, you may
337337
consider it more useful to permit linking proprietary applications with the
338338
library. If this is what you want to do, use the GNU Lesser General
339339
Public License instead of this License.
340-

LICENSE.txt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to [http://unlicense.org]

README.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
dockerfiles-centos-wordpress
2+
========================
3+
4+
(note: This originated from [jbfink](https://github.com/jbfink). I ported over to CentOS 7.)
5+
6+
Tested on Docker 1.0.0
7+
8+
(note: [Eugene Ware](http://github.com/eugeneware) has a Docker wordpress container build on nginx with some other goodies; you can check out his work [here](http://github.com/eugeneware/docker-wordpress-nginx).)
9+
10+
When you run the below commands, simply use sudo. This is a [known issue](https://twitter.com/docker/status/366040073793323008).)
11+
12+
This repo contains a recipe for making a [Docker](http://docker.io) container for Wordpress, using Linux, Apache and MySQL on CentOS7.
13+
To build, make sure you have Docker [installed](http://www.docker.io/gettingstarted/), clone this repo somewhere, and then run:
14+
15+
```
16+
# docker build -rm -t <yourname>/wordpress:centos7 .
17+
```
18+
19+
Run it:
20+
21+
```
22+
# CID=$(docker run -d -p 80 -p 22 <yourname>/wordpress:centos7)
23+
```
24+
25+
Check docker logs after running to see MySQL root password and Wordpress MySQL password, as so:
26+
27+
```
28+
# echo "$(docker logs $CID | grep password)"
29+
```
30+
31+
(note: you won't need the mysql root or the wordpress db password normally)
32+
33+
Then find the external port assigned to your container:
34+
35+
```
36+
# docker port $CID 80
37+
```
38+
39+
Visit in a webrowser, then fill out the form. No need to mess with wp-config.php, it's been auto-generated with proper values.
40+
41+
42+
Note that this image now has a user account (appropriately named "user") and passwordless sudo for that user account. The password is generated upon startup; check logs for "ssh user password", docker ps for the port assigned to 22, and something like this to get in:
43+
44+
```
45+
# ssh -p <port> user@localhost
46+
```
47+
48+

UNLICENSE.txt

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
This is free and unencumbered software released into the public domain.
3+
4+
Anyone is free to copy, modify, publish, use, compile, sell, or
5+
distribute this software, either in source code form or as a compiled
6+
binary, for any purpose, commercial or non-commercial, and by any
7+
means.
8+
9+
In jurisdictions that recognize copyright laws, the author or authors
10+
of this software dedicate any and all copyright interest in the
11+
software to the public domain. We make this dedication for the benefit
12+
of the public at large and to the detriment of our heirs and
13+
successors. We intend this dedication to be an overt act of
14+
relinquishment in perpetuity of all present and future rights to this
15+
software under copyright law.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
OTHER DEALINGS IN THE SOFTWARE.
24+
25+
For more information, please refer to [http://unlicense.org]
26+
27+
28+

foreground.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
read pid cmd state ppid pgrp session tty_nr tpgid rest < /proc/self/stat
4+
trap "kill -TERM -$pgrp; exit" EXIT TERM KILL SIGKILL SIGTERM SIGQUIT
5+
6+
7+
source /etc/apache2/envvars
8+
/usr/sbin/apachectl -D FOREGROUND

start.sh

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
__check() {
4+
if [ -f /var/www/html/wp-config.php ]; then
5+
exit
6+
fi
7+
}
8+
9+
__create_user() {
10+
# Create a user to SSH into as.
11+
SSH_USERPASS=`pwgen -c -n -1 8`
12+
useradd -G wheel user
13+
echo user:$SSH_USERPASS | chpasswd
14+
echo ssh user password: $SSH_USERPASS
15+
}
16+
17+
__mysql_config() {
18+
# Hack to get MySQL up and running... I need to look into it more.
19+
yum -y erase mariadb mariadb-server
20+
rm -rf /var/lib/mysql/ /etc/my.cnf
21+
yum -y install mariadb mariadb-server
22+
mysql_install_db
23+
chown -R mysql:mysql /var/lib/mysql
24+
/usr/bin/mysqld_safe &
25+
sleep 10
26+
}
27+
28+
__handle_passwords() {
29+
# Here we generate random passwords (thank you pwgen!). The first two are for mysql users, the last batch for random keys in wp-config.php
30+
WORDPRESS_DB="wordpress"
31+
MYSQL_PASSWORD=`pwgen -c -n -1 12`
32+
WORDPRESS_PASSWORD=`pwgen -c -n -1 12`
33+
# This is so the passwords show up in logs.
34+
echo mysql root password: $MYSQL_PASSWORD
35+
echo wordpress password: $WORDPRESS_PASSWORD
36+
echo $MYSQL_PASSWORD > /mysql-root-pw.txt
37+
echo $WORDPRESS_PASSWORD > /wordpress-db-pw.txt
38+
# There used to be a huge ugly line of sed and cat and pipe and stuff below,
39+
# but thanks to @djfiander's thing at https://gist.github.com/djfiander/6141138
40+
# there isn't now.
41+
sed -e "s/database_name_here/$WORDPRESS_DB/
42+
s/username_here/$WORDPRESS_DB/
43+
s/password_here/$WORDPRESS_PASSWORD/
44+
/'AUTH_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/
45+
/'SECURE_AUTH_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/
46+
/'LOGGED_IN_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/
47+
/'NONCE_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/
48+
/'AUTH_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/
49+
/'SECURE_AUTH_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/
50+
/'LOGGED_IN_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/
51+
/'NONCE_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/" /var/www/html/wp-config-sample.php > /var/www/html/wp-config.php
52+
}
53+
54+
__httpd_perms() {
55+
chown apache:apache /var/www/html/wp-config.php
56+
}
57+
58+
__start_mysql() {
59+
# systemctl start mysqld.service
60+
mysqladmin -u root password $MYSQL_PASSWORD
61+
mysql -uroot -p$MYSQL_PASSWORD -e "CREATE DATABASE wordpress; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY '$WORDPRESS_PASSWORD'; FLUSH PRIVILEGES;"
62+
killall mysqld
63+
sleep 10
64+
}
65+
66+
__run_supervisor() {
67+
supervisord -n
68+
}
69+
70+
# Call all functions
71+
__check
72+
__create_user
73+
__mysql_config
74+
__handle_passwords
75+
__httpd_perms
76+
__start_mysql
77+
__run_supervisor

0 commit comments

Comments
 (0)