Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Dockerfile
README.md
*.pyc
*.pyo
*.pyd
__pycache__
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
.idea
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM python:3.7

COPY requirements.txt /
WORKDIR /

RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip install gunicorn
RUN pip install --upgrade pytest

COPY app/ /app/
COPY tests/ /tests/

RUN pytest tests/

WORKDIR /app

ENV FLASK_APP=$WORKDIR/app.py

CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 app:app
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Your task should you choose to accept it is to:

* Create a Dockerfile to package this simple python app
* Create a script(s) for deploying the app to some cloud service that uses Docker images
* Submit a pull request with your work
* Create a Dockerfile to package this simple python app.
* Create a script(s) for deploying the app to some cloud service that uses Docker images.
* Submit a pull request with your work.

Script(s) should include:

* one or more commands to initialize the cloud service resources needed before first-run
* a command that deploys the app/docker image after verifying the unit tests complete succesfully.
* one or more commands to initialize the cloud service resources needed before first-run.
* a command that deploys the app/docker image after verifying the unit tests complete successfully.

Use any language you like for the scripts (shell, python, or whatever)
Use any language you like for the scripts (shell, python, or whatever).

My recomendation for deployment platform is [Google Cloud Run](https://cloud.google.com/run/).
My recommendation for deployment platform is [Google Cloud Run](https://cloud.google.com/run/).

Submit a pull request including all your changes when you are ready.
4 changes: 3 additions & 1 deletion app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

app = Flask(__name__)


@app.route('/')
def hello_world():
return 'Hello Evite!\n'


if __name__ == "__main__":
app.run(debug=True,host='0.0.0.0',port=int(os.environ.get('PORT', 8080)))
app.run(debug=True, host='0.0.0.0', port=int(os.environ.get('PORT', 8080)))
30 changes: 30 additions & 0 deletions ship.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -e

export PROJECT_ID='devops-test1-1420'
export SERVICE_NAME='hello-evite'
export GCLOUD_REGION='us-central1'

echo "Setting region to ${GCLOUD_REGION}..."
gcloud config set run/region $GCLOUD_REGION

echo "Setting project ID to ${PROJECT_ID}..."
gcloud config set project $PROJECT_ID

echo 'Enabling API services...'
gcloud services enable run.googleapis.com
gcloud services enable cloudbuild.googleapis.com

echo 'Building...'
gcloud builds submit --tag gcr.io/${PROJECT_ID}/${SERVICE_NAME}

if [ $? -eq 0 ]
then
echo "Image built. Deploying..."
gcloud beta run deploy ${SERVICE_NAME} --image gcr.io/${PROJECT_ID}/${SERVICE_NAME} --platform managed --allow-unauthenticated
exit 0
else
echo "Image failed to build." >&2
exit 1
fi
5 changes: 2 additions & 3 deletions tests/test_true.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
def test_true():
foo = True
assert foo == True, "foo should be true"

foo = True
assert foo == True, "foo should be true"