fixed docker

This commit is contained in:
Alexander Karpov 2023-01-03 01:31:02 +03:00
parent c2aa3b76c7
commit 410a73a4ec
9 changed files with 128 additions and 30 deletions

View File

@ -1,5 +1,6 @@
DATABASE_URL=postgres://postgres:postgres@127.0.0.1:5432/akarpov
CELERY_BROKER_URL=redis://localhost:6379/0
REDIS_URL=redis://localhost:6379/1
REDIS_HOST=localhost
USE_DOCKER=no
EMAIL_HOST=127.0.0.1:8025

View File

@ -5,8 +5,8 @@ IPYTHONDIR=/app/.ipython
DJANGO_READ_DOT_ENV_FILE=no
# Redis
# ------------------------------------------------------------------------------
REDIS_URL=redis://redis:6379/0
CELERY_BROKER_URL=redis://localhost:6379/0
REDIS_URL=redis://redis:6379/1
CELERY_BROKER_URL=redis://redis:6379/0
# Celery
# ------------------------------------------------------------------------------

16
.envs/.production/.django Normal file
View File

@ -0,0 +1,16 @@
# General
# CHANGE ON REAL SERVER
# ------------------------------------------------------------------------------
USE_DOCKER=yes
DJANGO_READ_DOT_ENV_FILE=no
# Redis
# ------------------------------------------------------------------------------
REDIS_URL=redis://redis:6379/0
CELERY_BROKER_URL=redis://localhost:6379/0
# Celery
# ------------------------------------------------------------------------------
# Flower
CELERY_FLOWER_USER=debug
CELERY_FLOWER_PASSWORD=debug

View File

@ -0,0 +1,7 @@
# PostgreSQL
# ------------------------------------------------------------------------------
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=akarpov
POSTGRES_USER=debug
POSTGRES_PASSWORD=debug

View File

@ -59,15 +59,3 @@ jobs:
- name: Tear down the Stack
run: docker-compose -f local.yml down
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v3
- name: Build the Stack
run: docker-compose -f production.yml build
- name: Tear down the Stack
run: docker-compose -f production.yml down

View File

@ -0,0 +1,88 @@
# Generated by Django 4.1.4 on 2023-01-01 21:26
from django.db import migrations, models
import django.db.models.deletion
import uuid
class Migration(migrations.Migration):
dependencies = [
("contenttypes", "0002_remove_content_type_name"),
("pipeliner", "0004_multiplicationblock_storage_and_more"),
]
operations = [
migrations.CreateModel(
name="BaseStorage",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
(
"polymorphic_ctype",
models.ForeignKey(
editable=False,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="polymorphic_%(app_label)s.%(class)s_set+",
to="contenttypes.contenttype",
),
),
],
options={
"abstract": False,
"base_manager_name": "objects",
},
),
migrations.AlterModelOptions(
name="storage",
options={"base_manager_name": "objects"},
),
migrations.RemoveField(
model_name="storage",
name="id",
),
migrations.CreateModel(
name="RunnerStorage",
fields=[
(
"basestorage_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="pipeliner.basestorage",
),
),
("data", models.JSONField(default=dict)),
],
options={
"abstract": False,
"base_manager_name": "objects",
},
bases=("pipeliner.basestorage",),
),
migrations.AddField(
model_name="storage",
name="basestorage_ptr",
field=models.OneToOneField(
auto_created=True,
default=123,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="pipeliner.basestorage",
),
preserve_default=False,
),
]

View File

@ -4,7 +4,6 @@ set -o errexit
set -o nounset
python manage.py makemigrations
python manage.py migrate auth
python manage.py migrate
rm -f './celerybeat.pid'
celery -A config.celery_app beat -l INFO

View File

@ -1,5 +1,4 @@
ARG PYTHON_VERSION=3.10-slim-bullseye
ARG PYTHON_VERSION=3.11-slim
# define an alias for the specfic python version used in this file.
@ -17,13 +16,6 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
# psycopg2 dependencies
libpq-dev
# Requirements are installed here to ensure they will be cached.
COPY ./requirements .
# Create Python Dependency and Sub-Dependency Wheels.
RUN pip wheel --wheel-dir /usr/src/app/wheels \
-r ${BUILD_ENVIRONMENT}.txt
# Python 'run' stage
FROM python as python-run-stage
@ -51,13 +43,15 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
# All absolute dir copies ignore workdir instruction. All relative dir copies are wrt to the workdir instruction
# copy python dependency wheels from python-build-stage
COPY --from=python-build-stage /usr/src/app/wheels /wheels/
# use wheels to install python dependencies
RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
&& rm -rf /wheels/
RUN pip install poetry
# Configuring poetry
RUN poetry config virtualenvs.create false
COPY pyproject.toml poetry.lock /
# Installing requirements
RUN poetry install
COPY --chown=django:django ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint

View File

@ -73,6 +73,11 @@
"auth.permission": {"ops": "all"},
"*.*": {},
}
CACHEOPS_REDIS = {
'host': env.db("REDIS_HOST", default="redis"),
'port': 6379, # default redis port
'db': 1,
}
# URLS
# ------------------------------------------------------------------------------