-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from GatorEducator/feature/dockerfile
Dockerfile
- Loading branch information
Showing
6 changed files
with
86 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Dockerfile | ||
.dockerignore | ||
.venv/ | ||
.git/ | ||
.gitignore | ||
# possibly need to ignore database if using remote | ||
# database.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM python:3.7.3-alpine | ||
MAINTAINER gkapfham@allegheny.edu | ||
|
||
ENV APP_DIR /quizagator | ||
ENV FLASK_PORT 5000 | ||
|
||
EXPOSE ${FLASK_PORT} | ||
|
||
# create and use the quizagator directory | ||
WORKDIR ${APP_DIR} | ||
|
||
# Copy the current folder to /quizagator in the image | ||
# This should include Pipfile.lock | ||
COPY . ${APP_DIR} | ||
|
||
# install pipenv and dependencies into the image's system python | ||
# (Don't use pipenv run to run things) | ||
RUN set -ex && pip install pipenv && pipenv install --deploy --system | ||
|
||
# the start command will run the production server | ||
CMD python run.py --host 0.0.0.0 --port ${FLASK_PORT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
"""Run this file to run the application""" | ||
|
||
# imports everything from the application folder | ||
import argparse | ||
|
||
from application import app | ||
|
||
app.secret_key = "$JLmL!eCQXyajbdu2LCJ&Vwqs2JGagg3B&FRfexCmKBV" | ||
|
||
# starts the server, debug mode is on | ||
app.debug = True | ||
app.run() | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"-d, --debug", | ||
dest="debug", | ||
default=False, | ||
action="store_true", | ||
help="set debug mode", | ||
) | ||
parser.add_argument( | ||
"--port", | ||
dest="port", | ||
type=int, | ||
default=5000, | ||
help="port to listen on (default: 5000)", | ||
) | ||
parser.add_argument( | ||
"--host", | ||
dest="host", | ||
type=str, | ||
default="0.0.0.0", | ||
help="host to serve from (default: 0.0.0.0)", | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
app.debug = args.debug | ||
app.run(args.host, args.port) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
IMAGE_NAME="gatoreducator/quizagator" | ||
TAG="latest" | ||
|
||
NAME="$IMAGE_NAME" | ||
if ! test -z "$TAG"; then | ||
NAME="$NAME:$TAG" | ||
fi | ||
|
||
docker image rm --force "$NAME" | ||
|
||
docker build -t "$NAME" . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
NAME="quizagator" | ||
IMAGE="gatoreducator/quizagator:latest" | ||
INNER_PORT="5000" | ||
OUTER_PORT="4201" | ||
|
||
|
||
docker stop "$NAME" | ||
docker rm "$NAME" | ||
|
||
docker run -d --name "$NAME" -p "${OUTER_PORT}:${INNER_PORT}" "$IMAGE" |