-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from emp7yhead/add_railway_deploy_instruction
Add railway deploy instruction and split dokerfile for dev and deploy
- Loading branch information
Showing
9 changed files
with
121 additions
and
11 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
## Развертывание Hexlet-Friends на Railway | ||
|
||
1. Создайте новый проект на Railway. Для успешного деплоя приложения вам понадобится база данных `PostgreSQL` и приложение | ||
2. Для добавления БД при создании проекта выберите `Provision PostgreSQL` | ||
3. После добавления БД, нажмите `+ New` -> `Github Repo`. В выпадающем списке выберите свой репозиторий с `Hexlet-friends`. Здесь возможно понадобится дать доступы Railway к вашим репозитория, если ранее вы их не настроили | ||
4. Переходим в настройки нашего приложения. Нам необходимо: | ||
|
||
- настроить переменные окружения на вкладке `Variables`. Вам понадобятся: | ||
|
||
- `PORT` - присвойте значение 8000, после нажмите на три вертикальные точки справа от переменной и выберите `Promote` - это позволит использовать данный порт для входа в приложение. | ||
- `GITHUB_AUTH_TOKEN` | ||
- `SECRET_KEY` | ||
- `POSTGRES_DB` | ||
- `POSTGRES_USER` | ||
- `POSTGRES_PASSWORD` | ||
- `POSTGRES_HOST` | ||
- `POSTGRES_PORT` | ||
|
||
Переменные `PostgreSQL` можно использовать через `Add reference` при создании переменной для приложения | ||
|
||
- выбрать ветку, изменения из которой будут отслеживаться в меню `Automatic Deployments` на вкладке `Settings` | ||
- в графе `Domains` нажмем кнопку `Generate Domain` для генерации домена для доступа к приложению | ||
- в меню `Deployments` открывает `Deploy Logs` и убеждаемся, что все работает | ||
|
||
```bash | ||
Performing system checks... | ||
System check identified no issues (0 silenced). | ||
You have 36 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, contributors, custom_auth, sessions. | ||
Run 'python manage.py migrate' to apply them. | ||
June 21, 2023 - 09:22:50 | ||
Django version 4.1.9, using settings 'config.settings' | ||
Starting development server at http://0.0.0.0:8000/ | ||
Quit the server with CONTROL-C. | ||
``` | ||
5. Как видим миграции не приняты, для этого перейдем вновь на вкладку `Settings` в настройках приложения: | ||
- в меню `Start Command` укажем `python manage.py migrate` | ||
- произойдет редеплой в ходе которого применятся миграции. Отследить выполнение команды можно в логах приложения | ||
- удалим команду из `Start Command` | ||
- убедимся по логам, что все в порядке | ||
```bash | ||
Performing system checks... | ||
Django version 4.1.9, using settings 'config.settings' | ||
Starting development server at http://0.0.0.0:8000/ | ||
Quit the server with CONTROL-C. | ||
``` | ||
6. Если необходимо выполнить заполнение БД, то в `Start Command` следует указать команду `python manage.py fetchdata <organization name>` | ||
7. Перейдем по ссылке в `Domains` в `Settings` и убедимся, что приложение работает |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM python:3.11-alpine as builder | ||
|
||
ENV PYTHONFAULTHANDLER=1 \ | ||
PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on \ | ||
POETRY_VERSION=1.2.2 \ | ||
POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_CREATE=false \ | ||
POETRY_CACHE_DIR='/var/cache/pypoetry' \ | ||
PATH="$PATH:/root/.local/bin" | ||
|
||
RUN apk add --no-cache \ | ||
gcc \ | ||
musl-dev \ | ||
postgresql-dev \ | ||
libffi-dev \ | ||
openssl-dev \ | ||
cargo \ | ||
curl \ | ||
gettext \ | ||
git \ | ||
make | ||
|
||
RUN curl -sSL https://install.python-poetry.org | python3 - \ | ||
&& poetry --version | ||
|
||
WORKDIR /project/ | ||
|
||
COPY pyproject.toml poetry.lock ./ | ||
|
||
RUN poetry install --extras psycopg2-binary | ||
|
||
WORKDIR /usr/local/src/hexlet-friends | ||
|
||
CMD ["make", "start"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ services: | |
django: | ||
build: | ||
context: . | ||
dockerfile: dockerfile.dev | ||
environment: | ||
- DEBUG=True | ||
env_file: | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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