Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23840aa

Browse files
john-fueledSuneet Choudhary
and
Suneet Choudhary
authored
feat(fly-io): Added fly.io template files (#475)
Added fly.io template files for a deployable Dockerfile and Githubactions.> 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 thatFly.io expects. When deploying the `dev` Dockerfile, Fly.io deploys hangdue to the `entrypoint` script running the gunicorn command which neverexits. Therefore a separate `compose/fly` folder has the necessarychanges to pass the build process.Addresses#466---------Co-authored-by: Suneet Choudhary <suneet@fueled.com>
1 parentd305b93 commit23840aa

File tree

7 files changed

+120
-6
lines changed

7 files changed

+120
-6
lines changed

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,7 @@ Session.vim
8383

8484
# Pycharm project modules
8585
.idea/
86+
87+
88+
### VSCode
89+
.vscode/

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
###Optional
3131
- Heroku Setup
32+
- Fly Setup
3233
- Ubuntu 20 LTS via[Ansible]
3334
- Celery with flower integration.
3435
- AWS S3 media storage

‎cookiecutter.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
,"add_newrelic" :"y"
1111
,"add_postgis":"n"
1212
,"add_heroku":"n"
13+
,"add_fly":"n"
1314
,"enable_whitenoise":"n"
1415
,"add_ansible":"y"
1516
,"letsencrypt":"y"

‎hooks/post_gen_project.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ if echo "{{ cookiecutter.add_heroku }}" | grep -iq "^n"; then
2929
rm -rf uwsgi.ini Procfile runtime.txt bin/post_compile
3030
fi
3131

32+
ifecho"{{ cookiecutter.add_fly }}"| grep -iq"^n";then
33+
rm .github/workflows/fly.yml
34+
rm -rf compose/fly
35+
fi
36+
3237
ifecho"{{ cookiecutter.add_ansible }}"| grep -iq"^n";then
3338
rm -rf provisioner Vagrantfile ansible.cfg
3439
fi
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name:Fly Deploy
2+
on:
3+
push:
4+
branches:
5+
-master
6+
jobs:
7+
deploy:
8+
name:Deploy app
9+
runs-on:ubuntu-latest
10+
steps:
11+
-uses:actions/checkout@v3
12+
-uses:superfly/flyctl-actions/setup-flyctl@master
13+
-run:flyctl deploy --dockerfile ./compose/fly/django/Dockerfile
14+
env:
15+
FLY_API_TOKEN:${{ "{{" }} secrets.FLY_API_TOKEN {{ "}}" }}

‎{{cookiecutter.github_repository}}/README.md‎

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
{{ cookiecutter.project_name }}
2-
==============================
1+
#{{ cookiecutter.project_name }}
32

4-
__Version:__ {{ cookiecutter.version }}
3+
**Version:** {{ cookiecutter.version }}
54

65
{{ cookiecutter.project_description }}
76

87
##Getting up and running
98

109
{% if cookiecutter.add_docker == 'y' %}
1110
!!! note
12-
For setting up locally using`Docker`, check[here](docs/backend/docker_setup.md)
11+
For setting up locally using`Docker`, check[here](docs/backend/docker_setup.md)
1312
{% endif %}
1413

1514
Minimum requirements:**pip, python3.9, poetry, redis &[PostgreSQL 11][install-postgres]{% if cookiecutter.add_postgis.lower() == "y" %} with postgis-2.4{% endif %}**, setup is tested on Mac OSX only.
@@ -43,7 +42,7 @@ Running `poetry lock` generates `poetry.lock` which has all versions pinned.
4342

4443
You can install Poetry by using`pip install --pre poetry` or by following the official installation guide[here](https://github.com/python-poetry/poetry#installation).
4544

46-
*Tip:* We recommend that you use this workflow and keep`pyproject.toml` as well as`poetry.lock` under version control to make sure all computers and environments run exactly the same code.
45+
_Tip:_ We recommend that you use this workflow and keep`pyproject.toml` as well as`poetry.lock` under version control to make sure all computers and environments run exactly the same code.
4746

4847
###Other tools
4948

@@ -61,13 +60,38 @@ poetry export --without-hashes -f requirements.txt -o requirements_dev.txt --wit
6160

6261
, respectively.
6362

64-
6563
##Deploying Project
6664

6765
The deployment are managed via travis, but for the first time you'll need to set the configuration values on each of the server.
6866

6967
Check out detailed server setup instruction[here](docs/backend/server_config.md).
7068

69+
{% if cookiecutter.add_fly == 'y' %}
70+
71+
###Develop on Fly.io
72+
73+
Create a[fly.io](https://fly.io) account.
74+
75+
Install`flyctl` and run the following commands to set up the Fly.io application, it will ask a series of questions regarding deployment configuration.
76+
77+
```
78+
brew install flyctl
79+
fly lauch
80+
```
81+
82+
When ready to deploy, simply run the command using the Fly Dockerfile:
83+
84+
```
85+
flyctl deploy --dockerfile ./compose/fly/django/Dockerfile
86+
```
87+
88+
There is also a Github Action provided`.github/workflows/fly.yml` to deploy the application on the`master` branch. In order to deploy from CI:
89+
90+
1. Create Fly Access Token[here](https://fly.io/user/personal_access_tokens).
91+
2. Add the`FLY_API_TOKEN` to the Github repo secrets[here](https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.github_repository}}/settings/secrets/actions)
92+
93+
{% endif %}
94+
7195
##How to release {{ cookiecutter.project_name }}
7296

7397
Execute the following commands:
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
ARG PYTHON_VERSION=3.9-slim-buster
2+
3+
# define an alias for the specfic python version used in this file.
4+
FROM python:${PYTHON_VERSION} as python
5+
6+
ENV POETRY_VERSION=1.3.2
7+
8+
ARG BUILD_ENVIRONMENT=dev
9+
ARG APP_HOME=/app
10+
11+
ENV PYTHONUNBUFFERED 1
12+
ENV PYTHONDONTWRITEBYTECODE 1
13+
ENV BUILD_ENV ${BUILD_ENVIRONMENT}
14+
15+
WORKDIR ${APP_HOME}
16+
17+
RUN addgroup --system django \
18+
&& adduser --system --ingroup django django
19+
20+
# Install required system dependencies
21+
RUN apt-get update && apt-get install --no-install-recommends -y \
22+
# dependencies for building Python packages
23+
build-essential \
24+
# psycopg2 dependencies
25+
libpq-dev \
26+
# Translations dependencies
27+
gettext \
28+
# Versatile image field & pillow \
29+
libmagic1 \
30+
libmagic-dev \
31+
32+
# cleaning up unused files
33+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
34+
&& rm -rf /var/lib/apt/lists/*
35+
36+
# Install Poetry
37+
RUN pip install --no-cache-dir poetry==${POETRY_VERSION}
38+
39+
COPY poetry.lock pyproject.toml ${APP_HOME}/
40+
41+
# Project initialization:
42+
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi
43+
44+
COPY --chown=django:django ./compose/dev/django/celery/worker/start /start-celeryworker
45+
RUN chmod +x /start-celeryworker
46+
47+
48+
COPY --chown=django:django ./compose/dev/django/celery/beat/start /start-celerybeat
49+
RUN chmod +x /start-celerybeat
50+
51+
52+
COPY ./compose/dev/django/celery/flower/start /start-flower
53+
RUN chmod +x /start-flower
54+
55+
COPY --chown=django:django . ${APP_HOME}
56+
57+
# make django owner of the WORKDIR directory as well.
58+
RUN chown django:django ${APP_HOME}
59+
60+
RUN python manage.py collectstatic --noinput
61+
62+
EXPOSE 8000
63+
64+
CMD ["gunicorn","--bind",":8000","--workers","2","wsgi:application"]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp