Skip to content

Commit

Permalink
Merge pull request #388 from hackforla/testHeroku
Browse files Browse the repository at this point in the history
Backend image deploys to heroku on master dpeloyment
  • Loading branch information
brodly authored Mar 8, 2020
2 parents a5980b3 + a06a563 commit a6c2476
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/Publish_Backend_Package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,17 @@ jobs:
dockerfile: server/Dockerfile
context: server
tags: "latest, ${{github.sha}}"
- name: Login to heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: heroku container:login
- name: Build and push heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
docker tag docker.pkg.github.com/hackforla/311-data/backend:${{github.sha}} registry.heroku.com/hackforla-311-data/web
docker push registry.heroku.com/hackforla-311-data/web
- name: Release
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: heroku container:release -a hackforla-311-data web
3 changes: 2 additions & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ RUN apt-get update && apt-get install -yq \
gfortran musl-dev

ENV DB_CONNECTION_STRING=REDACTED
ENV PORT=5000
COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt
Expand All @@ -13,6 +14,6 @@ COPY src/ /app

WORKDIR /app

EXPOSE 5000
EXPOSE $PORT

CMD ["python", "app.py"]
13 changes: 10 additions & 3 deletions server/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,22 @@
compress = Compress()


def environment_overrides():
if os.environ.get('DB_CONNECTION_STRING', None):
app.config['Settings']['Database']['DB_CONNECTION_STRING'] =\
os.environ.get('DB_CONNECTION_STRING')
if os.environ.get('PORT', None):
app.config['Settings']['Server']['PORT'] =\
os.environ.get('PORT')


def configure_app():
# Settings initialization
config = ConfigParser()
settings_file = os.path.join(os.getcwd(), 'settings.cfg')
config.read(settings_file)
app.config['Settings'] = config
if os.environ.get('DB_CONNECTION_STRING', None):
app.config['Settings']['Database']['DB_CONNECTION_STRING'] =\
os.environ.get('DB_CONNECTION_STRING')
environment_overrides()
app.config["STATIC_DIR"] = os.path.join(os.getcwd(), "static")
os.makedirs(os.path.join(app.config["STATIC_DIR"], "temp"), exist_ok=True)

Expand Down

0 comments on commit a6c2476

Please sign in to comment.