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

Backend image deploys to heroku on master dpeloyment #388

Merged
merged 1 commit into from
Mar 8, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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