-
Notifications
You must be signed in to change notification settings - Fork 1
enable local development #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e3e92bf
a55767d
6f657a8
d43ef45
a27efc0
b61eb03
6f3f719
be9867e
965682a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# start with the `delphi_database` image | ||
FROM delphi_database | ||
|
||
# create the `epicast2` database | ||
ENV MYSQL_DATABASE epicast2 | ||
|
||
# create the `epi` user account with a development-only password | ||
ENV MYSQL_USER user | ||
ENV MYSQL_PASSWORD pass | ||
|
||
# provide DDL which will create empty tables at container startup | ||
# note that files are executed in order of filename alphabetically, so here | ||
# destination files are named such that table definitions are executed prior to | ||
# data insertions | ||
COPY repos/delphi/www-epicast/src/ddl/epicast2.sql /docker-entrypoint-initdb.d/0_epicast2.sql | ||
COPY repos/delphi/www-epicast/src/ddl/development_data.sql /docker-entrypoint-initdb.d/1_development_data.sql |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# `delphi_database_epicast` | ||
|
||
This image extends Delphi's database by: | ||
|
||
- adding the `epi` user account | ||
- adding the `epicast2` database | ||
- creating and minimally populating tables in `epicast2` | ||
|
||
To start a container from this image, run: | ||
|
||
```bash | ||
docker run --rm -p 13306:3306 \ | ||
--network delphi-net --name delphi_database_epicast \ | ||
delphi_database_epicast | ||
``` | ||
|
||
For debugging purposes, you can interactively connect to the database inside | ||
the container using a `mysql` client (either installed locally or supplied via | ||
a docker image) like this: | ||
|
||
```bash | ||
mysql --user=user --password=pass --port 13306 --host 127.0.0.1 epicast2 | ||
``` | ||
|
||
Note that using host `localhost` may fail on some platforms as mysql will | ||
attempt, and fail, to use a Unix socket. Using `127.0.0.1`, which implies | ||
TCP/IP, works instead. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# start with the `delphi_web` image | ||
FROM delphi_web | ||
|
||
# enable mod_rewrite, aka RewriteEngine | ||
RUN a2enmod rewrite | ||
|
||
# enable mod_headers | ||
RUN a2enmod headers | ||
|
||
# create an empty htpasswd file | ||
RUN touch /var/www/passwords | ||
|
||
# deploy the Epicast website (see `www-epicast/deploy.json`) | ||
# deploy files in an order that tries to take advantage of build caching | ||
|
||
COPY repos/delphi/www-epicast/site/images/* /var/www/html/images/ | ||
COPY repos/delphi/www-epicast/site/images/flags/* /var/www/html/images/flags/ | ||
COPY repos/delphi/www-epicast/site/data/* /var/www/html/data/ | ||
|
||
COPY repos/delphi/www-epicast/site/css/* /var/www/html/css/ | ||
COPY repos/delphi/www-epicast/site/js/*.js /var/www/html/js/ | ||
COPY repos/delphi/www-epicast/site/js/us-map /var/www/html/js/us-map | ||
COPY repos/delphi/www-epicast/site/common/* /var/www/html/common/ | ||
COPY repos/delphi/www-epicast/site/*.php /var/www/html/ | ||
|
||
# point to the local development database (overwrites `common/settings.php`) | ||
COPY repos/delphi/www-epicast/dev/docker/web/epicast/assets/settings.php /var/www/html/common/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# `delphi_web_epicast` | ||
|
||
This image starts with Delphi's web server and adds the sources necessary for | ||
hosting the Epicast website. It further extends Delphi's web server by: | ||
|
||
- enabling the `mod_rewrite` extension | ||
- enabling the `mod_headers` extension | ||
- creating an empty `htpasswd` file | ||
|
||
This image includes the file | ||
[`settings.php`](assets/settings.php), which points to a local | ||
container running the | ||
[`delphi_database_epicast` image](../../database/epicast/README.md). | ||
|
||
To start a container from this image, run: | ||
|
||
```bash | ||
docker run --rm -p 10080:80 \ | ||
--network delphi-net --name delphi_web_epicast \ | ||
delphi_web_epicast | ||
``` | ||
|
||
You should be able to login and interact with the website (e.g. submitting | ||
predictions) by visiting `http://localhost:10080/` in a web browser. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
/* Settings and secrets for local development of the Epicast website. */ | ||
|
||
$dbHost = 'delphi_database_epicast'; | ||
$dbPort = 3306; | ||
$dbUser = 'user'; | ||
$dbPass = 'pass'; | ||
$dbName = 'epicast2'; | ||
|
||
$epicastAdmin = array( | ||
'name' => 'Delphi Developer', | ||
'email' => 'fake_email_address', | ||
); | ||
?> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
RewriteEngine On | ||
|
||
## Resrtict access to known users ## | ||
## Restrict access to known users or docker development ## | ||
AuthType Basic | ||
AuthName "Restricted Site: Crowdcast" | ||
AuthBasicProvider file | ||
AuthUserFile /var/www/passwords | ||
Require user cctest | ||
## Resrtict access to known users ## | ||
Require ip 172.16.0.0/12 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this supposed to be 127.16.0.0/12? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for taking a close look! that's a great question. 172 is correct in this case (but wow that is similar to 127...)
The idea here is that we either want a valid user or someone connecting from a local private network, particularly Docker's network. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah -- the commit message says 127. probably muscle memory :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oof, definitely muscle memory. glad i typo'd the commit message and not the htaccess file 😄 |
||
## Restrict access to known users or docker development ## | ||
|
||
## Compress Files ## | ||
<IfModule mod_deflate.c> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to make this work for a pandemic setup where, e.g., my development machine is on campus and I'm shelling into it from home? Are we talking X forwarding or is there a way to expose this address outside localhost?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh interesting, that's a good use-case. no need to X-forward. you should be able to use a
reversessh tunnel to forward localhost:10080 on your at-home machine to localhost:10080 on your at-work machine.from your at-home machine, this command should work:
This works by listening on port 10080 at-home and tunneling connections to port 10080 at-work. (The first
localhost:10080
is where to listen at-home, the secondlocalhost:10080
is where to connect at-work.)This is probably something that should go in the guide. Do you mind letting me know if this works for you?
edit: fix terrible typo, this should be a forward tunnel, not reverse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and to be clear, after the
ssh
command above, you can then openhttp://localhost:10080/
on your at-home machine, and you should see your "local" (at-work) instance of the website.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the db and web server running in docker on my work machine, and I can load the site in lynx from there. Alas, the ssh tunnel fails:
--which seems weird; I'm not a tunneling pro but I've done something like this before. I'll have more time to debug tomorrow morning.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh my bad. this should be a forward tunnel, not reverse. just need to swap out
-R
with-L
as in:(replaced
localhost
with127.0.0.1
to be extra safe)