-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fly-io): Added fly.io template files (#475)
Added fly.io template files for a deployable Dockerfile and Github actions. > Why was this change necessary? Spin up a hosted development environment fast. > How does it address the problem? Adds fly.io as an optional deployment destination. > Are there any side effects? The local and dev Dockerfiles do not have the same configuration that Fly.io expects. When deploying the `dev` Dockerfile, Fly.io deploys hang due to the `entrypoint` script running the gunicorn command which never exits. Therefore a separate `compose/fly` folder has the necessary changes to pass the build process. Addresses #466 --------- Co-authored-by: Suneet Choudhary <[email protected]>
- Loading branch information
1 parent
d305b93
commit 23840aa
Showing
7 changed files
with
120 additions
and
6 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 |
---|---|---|
|
@@ -83,3 +83,7 @@ Session.vim | |
|
||
# Pycharm project modules | ||
.idea/ | ||
|
||
|
||
### VSCode | ||
.vscode/ |
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
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
15 changes: 15 additions & 0 deletions
15
{{cookiecutter.github_repository}}/.github/workflows/fly.yml
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,15 @@ | ||
name: Fly Deploy | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
deploy: | ||
name: Deploy app | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- run: flyctl deploy --dockerfile ./compose/fly/django/Dockerfile | ||
env: | ||
FLY_API_TOKEN: ${{ "{{" }} secrets.FLY_API_TOKEN {{ "}}" }} |
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
64 changes: 64 additions & 0 deletions
64
{{cookiecutter.github_repository}}/compose/fly/django/Dockerfile
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,64 @@ | ||
ARG PYTHON_VERSION=3.9-slim-buster | ||
|
||
# define an alias for the specfic python version used in this file. | ||
FROM python:${PYTHON_VERSION} as python | ||
|
||
ENV POETRY_VERSION=1.3.2 | ||
|
||
ARG BUILD_ENVIRONMENT=dev | ||
ARG APP_HOME=/app | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV BUILD_ENV ${BUILD_ENVIRONMENT} | ||
|
||
WORKDIR ${APP_HOME} | ||
|
||
RUN addgroup --system django \ | ||
&& adduser --system --ingroup django django | ||
|
||
# Install required system dependencies | ||
RUN apt-get update && apt-get install --no-install-recommends -y \ | ||
# dependencies for building Python packages | ||
build-essential \ | ||
# psycopg2 dependencies | ||
libpq-dev \ | ||
# Translations dependencies | ||
gettext \ | ||
# Versatile image field & pillow \ | ||
libmagic1 \ | ||
libmagic-dev \ | ||
|
||
# cleaning up unused files | ||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Poetry | ||
RUN pip install --no-cache-dir poetry==${POETRY_VERSION} | ||
|
||
COPY poetry.lock pyproject.toml ${APP_HOME}/ | ||
|
||
# Project initialization: | ||
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi | ||
|
||
COPY --chown=django:django ./compose/dev/django/celery/worker/start /start-celeryworker | ||
RUN chmod +x /start-celeryworker | ||
|
||
|
||
COPY --chown=django:django ./compose/dev/django/celery/beat/start /start-celerybeat | ||
RUN chmod +x /start-celerybeat | ||
|
||
|
||
COPY ./compose/dev/django/celery/flower/start /start-flower | ||
RUN chmod +x /start-flower | ||
|
||
COPY --chown=django:django . ${APP_HOME} | ||
|
||
# make django owner of the WORKDIR directory as well. | ||
RUN chown django:django ${APP_HOME} | ||
|
||
RUN python manage.py collectstatic --noinput | ||
|
||
EXPOSE 8000 | ||
|
||
CMD ["gunicorn", "--bind", ":8000", "--workers", "2", "wsgi:application"] |