Skip to content
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

Ease building and serving for local development using docker-compose #321

Merged
merged 1 commit into from Apr 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions Dockerfile
@@ -0,0 +1,27 @@
# Copyright (C) 2018 Sebastian Pipping <sebastian@pipping.org>
# Licensed under the MIT license

# Base image
FROM python:2.7-stretch

# Start off with the most updated image possible
RUN apt-get update && apt-get --yes dist-upgrade

# Install non-PyPI dependencies
RUN apt-get update && apt-get install --no-install-recommends --yes -V \
gatling \
git

# Install app including dependencies, whitelist approach (size, anti-leak)
COPY docker-entrypoint.sh /root/pythonjobs/
COPY jobs/ /root/pythonjobs/jobs/
WORKDIR /root/pythonjobs
RUN git clone --depth 1 https://github.com/pythonjobs/template.git
RUN pip install -r template/requirements.txt

# Build website first time
RUN template/build.py /root/pythonjobs/

# Sync and serve website
EXPOSE 80
ENTRYPOINT ["/root/pythonjobs/docker-entrypoint.sh"]
11 changes: 10 additions & 1 deletion README.md
Expand Up @@ -159,7 +159,16 @@ Sure, here: http://www.seethestats.com/site/pythonjobs.github.io

### Can I run the site locally to preview my submission?

The easiest way to preview your submission is to build the site locally. You can use almost the exact same process we use to build the site on your own PC:
The easiest way to preview your submission is to build the site locally.
If you have Docker and [docker-compose](https://docs.docker.com/compose/) installed, run

```console
$ docker-compose up
```

and browse to http://127.0.0.1/50080/ once it says it's serving.

Alternatively, you can use almost the exact same process we use to build the site on your own PC:

1. Install hyde - hyde.github.io <code>pip install hyde</code>
2. Install fin - <code>pip install fin</code>
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,12 @@
# Copyright (C) 2018 Sebastian Pipping <sebastian@pipping.org>
# Licensed under the MIT license

version: "3"

services:
pythonjobs:
build: .
ports:
- 50080:80
volumes:
- ./jobs:/root/pythonjobs/jobs
29 changes: 29 additions & 0 deletions docker-entrypoint.sh
@@ -0,0 +1,29 @@
#! /bin/bash
# Copyright (C) 2018 Sebastian Pipping <sebastian@pipping.org>
# Licensed under the MIT license

set -e

cd /root/pythonjobs

# Sync potential changes done after building the image
( cd template && git pull origin master )
./template/build.py .

# Be helpful about non-standard port/URL
cat <<INFO_END

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X Starting to serve at http://127.0.0.1:50080/ X
X ^^^ X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
INFO_END

gatling_params=(
-F # no FTP
-S # no SMB
-d # enable directory listings
-c template/hyde/deploy # dir to serve and change into
)
exec gatling "${gatling_params[@]}"