Skip to content

Commit 77d3729

Browse files
authored
Merge pull request #13 from dfarrow0/dev
enable local development
2 parents e46227a + 965682a commit 77d3729

23 files changed

+1086
-1538
lines changed

deploy.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@
1010
"dst": "/var/www/html/cc-test/.htaccess",
1111
"add-header-comment": false
1212
},
13-
"// service worker",
14-
{
15-
"type": "move",
16-
"src": "site/sw.js",
17-
"dst": "/var/www/html/cc-test/sw.js",
18-
"add-header-comment": true
19-
},
2013
"// web sources",
2114
{
2215
"type": "move",
@@ -36,7 +29,7 @@
3629
"type": "move",
3730
"src": "site/css/",
3831
"dst": "/var/www/html/cc-test/css/",
39-
"match": "^.*\\.(css|php)$",
32+
"match": "^.*\\.(php)$",
4033
"add-header-comment": true
4134
},
4235
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# start with the `delphi_database` image
2+
FROM delphi_database
3+
4+
# create the `epicast2` database
5+
ENV MYSQL_DATABASE epicast2
6+
7+
# create the `epi` user account with a development-only password
8+
ENV MYSQL_USER user
9+
ENV MYSQL_PASSWORD pass
10+
11+
# provide DDL which will create empty tables at container startup
12+
# note that files are executed in order of filename alphabetically, so here
13+
# destination files are named such that table definitions are executed prior to
14+
# data insertions
15+
COPY repos/delphi/www-epicast/src/ddl/epicast2.sql /docker-entrypoint-initdb.d/0_epicast2.sql
16+
COPY repos/delphi/www-epicast/src/ddl/development_data.sql /docker-entrypoint-initdb.d/1_development_data.sql

dev/docker/database/epicast/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# `delphi_database_epicast`
2+
3+
This image extends Delphi's database by:
4+
5+
- adding the `epi` user account
6+
- adding the `epicast2` database
7+
- creating and minimally populating tables in `epicast2`
8+
9+
To start a container from this image, run:
10+
11+
```bash
12+
docker run --rm -p 13306:3306 \
13+
--network delphi-net --name delphi_database_epicast \
14+
delphi_database_epicast
15+
```
16+
17+
For debugging purposes, you can interactively connect to the database inside
18+
the container using a `mysql` client (either installed locally or supplied via
19+
a docker image) like this:
20+
21+
```bash
22+
mysql --user=user --password=pass --port 13306 --host 127.0.0.1 epicast2
23+
```
24+
25+
Note that using host `localhost` may fail on some platforms as mysql will
26+
attempt, and fail, to use a Unix socket. Using `127.0.0.1`, which implies
27+
TCP/IP, works instead.

dev/docker/web/epicast/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# start with the `delphi_web` image
2+
FROM delphi_web
3+
4+
# enable mod_rewrite, aka RewriteEngine
5+
RUN a2enmod rewrite
6+
7+
# enable mod_headers
8+
RUN a2enmod headers
9+
10+
# create an empty htpasswd file
11+
RUN touch /var/www/passwords
12+
13+
# deploy the Epicast website (see `www-epicast/deploy.json`)
14+
# deploy files in an order that tries to take advantage of build caching
15+
16+
COPY repos/delphi/www-epicast/site/images/* /var/www/html/images/
17+
COPY repos/delphi/www-epicast/site/images/flags/* /var/www/html/images/flags/
18+
COPY repos/delphi/www-epicast/site/data/* /var/www/html/data/
19+
20+
COPY repos/delphi/www-epicast/site/css/* /var/www/html/css/
21+
COPY repos/delphi/www-epicast/site/js/*.js /var/www/html/js/
22+
COPY repos/delphi/www-epicast/site/js/us-map /var/www/html/js/us-map
23+
COPY repos/delphi/www-epicast/site/common/* /var/www/html/common/
24+
COPY repos/delphi/www-epicast/site/*.php /var/www/html/
25+
26+
# point to the local development database (overwrites `common/settings.php`)
27+
COPY repos/delphi/www-epicast/dev/docker/web/epicast/assets/settings.php /var/www/html/common/

dev/docker/web/epicast/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# `delphi_web_epicast`
2+
3+
This image starts with Delphi's web server and adds the sources necessary for
4+
hosting the Epicast website. It further extends Delphi's web server by:
5+
6+
- enabling the `mod_rewrite` extension
7+
- enabling the `mod_headers` extension
8+
- creating an empty `htpasswd` file
9+
10+
This image includes the file
11+
[`settings.php`](assets/settings.php), which points to a local
12+
container running the
13+
[`delphi_database_epicast` image](../../database/epicast/README.md).
14+
15+
To start a container from this image, run:
16+
17+
```bash
18+
docker run --rm -p 10080:80 \
19+
--network delphi-net --name delphi_web_epicast \
20+
delphi_web_epicast
21+
```
22+
23+
You should be able to login and interact with the website (e.g. submitting
24+
predictions) by visiting `http://localhost:10080/` in a web browser.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
/* Settings and secrets for local development of the Epicast website. */
4+
5+
$dbHost = 'delphi_database_epicast';
6+
$dbPort = 3306;
7+
$dbUser = 'user';
8+
$dbPass = 'pass';
9+
$dbName = 'epicast2';
10+
11+
$epicastAdmin = array(
12+
'name' => 'Delphi Developer',
13+
'email' => 'fake_email_address',
14+
);
15+
?>

site/.htaccess

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
RewriteEngine On
22

3-
## Resrtict access to known users ##
3+
## Restrict access to known users or docker development ##
44
AuthType Basic
55
AuthName "Restricted Site: Crowdcast"
66
AuthBasicProvider file
77
AuthUserFile /var/www/passwords
88
Require user cctest
9-
## Resrtict access to known users ##
9+
Require ip 172.16.0.0/12
10+
## Restrict access to known users or docker development ##
1011

1112
## Compress Files ##
1213
<IfModule mod_deflate.c>

0 commit comments

Comments
 (0)