diff --git a/.env.template b/.env.template index d329457..a56bf71 100644 --- a/.env.template +++ b/.env.template @@ -1,28 +1,28 @@ -ESI_CLIENT_ID= -ESI_SECRET_KEY= -ESI_CALLBACK_URL= -ESI_USER_AGENT= +ESI_CLIENT_ID=placeholder-client-id +ESI_SECRET_KEY=placeholder-secret-key +ESI_CALLBACK_URL=http://localhost:8000/esi/callback/ +ESI_USER_AGENT=marbas-dev-agent -REDIS_URL= -REDIS_PORT= -REDIS_DB= +REDIS_URL=redis +REDIS_PORT=6379 +REDIS_DB=0 REDIS_PASSWORD= REDIS_USER= -SQLITE_DB_PATH= -POSTGRES_HOST= -POSTGRES_PORT= -POSTGRES_PASSWORD= -POSTGRES_USER= -POSTGRES_DB= +SQLITE_DB_PATH=db.sqlite3 +POSTGRES_HOST=db +POSTGRES_PORT=5432 +POSTGRES_PASSWORD=marbas +POSTGRES_USER=marbas +POSTGRES_DB=marbas -DRF_SECRET_KEY= -DRF_DEBUG= -DEBUG= -ALLOWED_HOSTS= -CORS_ALLOWED_ORIGINS= -CSRF_TRUSTED_ORIGINS= +DRF_SECRET_KEY=django-insecure-dev-key-change-me +DRF_DEBUG=True +DEBUG=True +ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0 +CORS_ALLOWED_ORIGINS=http://localhost:8000,http://127.0.0.1:8000 +CSRF_TRUSTED_ORIGINS=http://localhost:8000,http://127.0.0.1:8000 -OIDC_RP_CLIENT_ID= -OIDC_WELLKNOWN= -OIDC_CACHE_USERINFO= \ No newline at end of file +OIDC_RP_CLIENT_ID=placeholder-oidc-client-id +OIDC_WELLKNOWN=https://login.eveonline.com/.well-known/openid-configuration +OIDC_CACHE_USERINFO=True \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 41a83bb..96ebe1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,14 +6,13 @@ ENV PYTHONDONTWRITEBYTECODE=1 RUN adduser -u 5678 --disabled-password --gecos "" appuser WORKDIR /app -COPY --chown=appuser:appuser manage.py /app/manage.py + COPY requirements.txt . RUN python -m pip install --no-cache-dir --upgrade -r requirements.txt -COPY --chown=appuser:appuser marbas /app/marbas -COPY --chown=appuser:appuser sde /app/sde -COPY --chown=appuser:appuser api /app/api -COPY --chown=appuser:appuser authentication /app/authentication -#COPY --chown=appuser:appuser static /app/static + +RUN mkdir -p /app/static && chown appuser:appuser /app/static + +COPY --chown=appuser:appuser . /app USER appuser EXPOSE 8000 diff --git a/api/tasks.py b/api/tasks.py new file mode 100644 index 0000000..4b39ee2 --- /dev/null +++ b/api/tasks.py @@ -0,0 +1,9 @@ +from celery import Celery + +app = Celery( + 'prod', + broker='redis://localhost:6379/0' +) + +if __name__ == '__main__': + app.start() \ No newline at end of file diff --git a/api/views.py b/api/views.py index 27e8b98..d4a0be1 100644 --- a/api/views.py +++ b/api/views.py @@ -90,7 +90,9 @@ def reprocess_eval(request): ep_items = request.data.get("ep_items") efficiency = request.data.get("efficiency", 0.55) - matprices = {item["typeID"]: {'sell': item["prices"]["sell"]["min"], 'buy': item["prices"]["buy"]["max"]} for item in ep_mat['items']} + matprices = {item["typeID"]: {'sell': item["prices"]["sell"]["min"], + 'buy': item["prices"]["buy"]["max"]} + for item in ep_mat['items']} item_reprocess = [] for rawitem in ep_items["items"]: diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 80779c1..880bdd6 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,42 +1,33 @@ services: - migrations: - image: marbas:local - build: - context: . - dockerfile: Dockerfile - env_file: - - .env - user: "1000:1000" - volumes: - - ./marbas:/app/marbas - - ./api:/app/api - - ./sde:/app/sde - - ./authentication:/app/authentication - - ./manage.py:/app/manage.py - - ./static:/app/static - command: sh -c "python manage.py makemigrations && python manage.py migrate" - depends_on: - db: - condition: service_healthy - - eveal: + app_base: &app_base image: marbas:local build: context: . dockerfile: Dockerfile env_file: - .env + user: "${UID:-1000}:${GID:-1000}" + volumes: + - .:/app:z + depends_on: + db: + condition: service_healthy + + migrations: + <<: *app_base + command: sh -c "python manage.py makemigrations && python manage.py migrate" + + import_sde: + <<: *app_base + command: python manage.py import_sde /app/static_eve/sde/fsd + depends_on: + migrations: + condition: service_completed_successfully + + eveal: + <<: *app_base ports: - "8000:8000" - user: "1000:1000" - volumes: - - ./marbas:/app/marbas - - ./api:/app/api - - ./sde:/app/sde - - ./authentication:/app/authentication - - ./manage.py:/app/manage.py - - ./static_eve:/app/static_eve - - ./static:/app/static command: ["uvicorn", "marbas.asgi:application", "--host", "0.0.0.0", "--port", "8000", "--reload"] healthcheck: test: python manage.py health_check @@ -48,8 +39,19 @@ services: condition: service_healthy migrations: condition: service_completed_successfully -# elasticsearch: -# condition: service_healthy + import_sde: + condition: service_completed_successfully + + worker: + <<: *app_base + command: celery -A marbas worker -l info + depends_on: + redis: + condition: service_healthy + db: + condition: service_healthy + migrations: + condition: service_completed_successfully redis: image: redis:latest @@ -64,7 +66,7 @@ services: ports: - "5432:5432" volumes: - - marbas_dbdata:/var/lib/postgresql/data + - marbas_dbdata:/var/lib/postgresql/data:Z env_file: - .env healthcheck: diff --git a/requirements.txt b/requirements.txt index 7dffd83..5517909 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,4 +13,5 @@ django-esi django-health-check mozilla-django-oidc django-cors-headers -whitenoise \ No newline at end of file +whitenoise +celery \ No newline at end of file