Compare commits
No commits in common. "1c08f433d4d90056f44bbcb2e910d597f1bc091e" and "254bf2bdf0d0c19d59bc2775cd78f1fa0c21f892" have entirely different histories.
1c08f433d4
...
254bf2bdf0
32
.env.example
32
.env.example
@ -1,32 +0,0 @@
|
|||||||
####################################################################################################
|
|
||||||
# Example configuration. Must be edited and copied to ".env" next to the compose.yaml
|
|
||||||
####################################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
# Path to to mount as the directory for static data. Must be served by a webserver on the /static path
|
|
||||||
DJANGO_STATIC_VOL=/path/to/static/root
|
|
||||||
|
|
||||||
# Path to the media root. Must be served by a webserver on the media URL
|
|
||||||
DJANGO_MEDIA_VOL=/path/to/media/root
|
|
||||||
|
|
||||||
# folder for DB
|
|
||||||
PGDATA_VOL=/path/to/pgdata
|
|
||||||
|
|
||||||
# Port to serve the App
|
|
||||||
PORT=8000
|
|
||||||
|
|
||||||
# Secret Key. Must be edited before deployment
|
|
||||||
DJANGO_SECRET_KEY=534hj5jgh4365ghj35jgh245jgh24
|
|
||||||
|
|
||||||
# Allowed host to be accessed. Currently it is only possible to specify a single URL
|
|
||||||
DJANGO_ALLOWED_HOST=lab.example.com
|
|
||||||
|
|
||||||
# Media URL for images and other content
|
|
||||||
DJANGO_MEDIA_URL=media.lab.example.com/
|
|
||||||
|
|
||||||
# DO NOT SET DEBUG MODE IN PRODUCTION
|
|
||||||
# DJANGO_FORCE_DEV_MODE=True
|
|
||||||
|
|
||||||
# Set this password if you want to use a custom postgres password. The db should be confined inside the docker network.
|
|
||||||
# Using the standard PW is therefore not a problem
|
|
||||||
# DJANGO_POSTGRESQL_PW=myfancynewpassword123donotsharemewithanyone
|
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -125,6 +125,3 @@ dmypy.json
|
|||||||
|
|
||||||
|
|
||||||
myenv/*
|
myenv/*
|
||||||
|
|
||||||
run/*
|
|
||||||
.env
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
RUN apk add --no-cache python3 py3-pip python3-dev py3-setuptools gcc python3-dev jpeg-dev zlib-dev musl-dev py3-gunicorn curl
|
RUN apk add --no-cache python3 py3-pip python3-dev py3-setuptools gcc python3-dev jpeg-dev zlib-dev musl-dev py3-gunicorn
|
||||||
COPY . /home/shimatta/kenkyusho
|
COPY . /home/shimatta/kenkyusho
|
||||||
WORKDIR /home/shimatta/kenkyusho
|
WORKDIR /home/shimatta/kenkyusho
|
||||||
RUN python3 -m venv /home/shimatta/kenkyusho/.venv && . /home/shimatta/kenkyusho/.venv/bin/activate && pip install -r requirements.txt
|
RUN python3 -m venv /home/shimatta/kenkyusho/.venv && . /home/shimatta/kenkyusho/.venv/bin/activate && pip install -r requirements.txt
|
||||||
|
48
compose.yaml
48
compose.yaml
@ -1,48 +0,0 @@
|
|||||||
services:
|
|
||||||
shimatta-kenkyusho-web:
|
|
||||||
build: .
|
|
||||||
volumes:
|
|
||||||
- "${DJANGO_STATIC_VOL:-./run/static}:/var/static"
|
|
||||||
- "${DJANGO_MEDIA_VOL:-./run/media}:/var/media"
|
|
||||||
environment:
|
|
||||||
DJANGO_POSTGRESQL_PW: "${DJANGO_POSTGRESQL_PW:-p4ssw0rd}"
|
|
||||||
DJANGO_POSTGRESQL_USER: "postgres"
|
|
||||||
DJANGO_SECRET_KEY: "${DJANGO_SECRET_KEY}"
|
|
||||||
DJANGO_ALLOWED_HOST: "${DJANGO_ALLOWED_HOST}"
|
|
||||||
DJANGO_STATIC_ROOT: "/var/static"
|
|
||||||
DJANGO_MEDIA_URL: "${DJANGO_MEDIA_URL}"
|
|
||||||
DJANGO_MEDIA_ROOT: "/var/media"
|
|
||||||
DJANGO_POSTGRESQL_SOCKET: "shimatta-kenkyusho-db"
|
|
||||||
DJANGO_POSTGRESQL_PORT: "5432"
|
|
||||||
DJANGO_FORCE_DEV_MODE: ${DJANGO_FORCE_DEV_MODE:-False}
|
|
||||||
ports:
|
|
||||||
- "${PORT}:8000"
|
|
||||||
networks:
|
|
||||||
- backendnet
|
|
||||||
depends_on:
|
|
||||||
shimatta-kenkyusho-db:
|
|
||||||
condition: service_healthy
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "curl -f localhost:8000/healthcheck"]
|
|
||||||
interval: 5s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
start_period: 30s
|
|
||||||
|
|
||||||
shimatta-kenkyusho-db:
|
|
||||||
image: postgres:16.5-alpine
|
|
||||||
environment:
|
|
||||||
POSTGRES_PASSWORD: "${DJANGO_POSTGRESQL_PW:-p4ssw0rd}"
|
|
||||||
POSTGRES_DB: "shimatta_kenkyusho"
|
|
||||||
volumes:
|
|
||||||
- "${PGDATA_VOL:-./run/pgdata}:/var/lib/postgresql/data"
|
|
||||||
networks:
|
|
||||||
- backendnet
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
||||||
interval: 5s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
|
|
||||||
networks:
|
|
||||||
backendnet:
|
|
@ -3,4 +3,4 @@ source /home/shimatta/kenkyusho/.venv/bin/activate
|
|||||||
cd /home/shimatta/kenkyusho/shimatta_kenkyusho
|
cd /home/shimatta/kenkyusho/shimatta_kenkyusho
|
||||||
python manage.py migrate --settings shimatta_kenkyusho.settings_production
|
python manage.py migrate --settings shimatta_kenkyusho.settings_production
|
||||||
python manage.py collectstatic --settings shimatta_kenkyusho.settings_production --noinput
|
python manage.py collectstatic --settings shimatta_kenkyusho.settings_production --noinput
|
||||||
gunicorn -w 4 --bind 0.0.0.0:8000 shimatta_kenkyusho.wsgi:application
|
gunicorn -w 4 shimatta_kenkyusho.wsgi:application
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
source /home/shimatta/kenkyusho/.venv/bin/activate
|
|
||||||
cd /home/shimatta/kenkyusho/shimatta_kenkyusho
|
|
||||||
python manage.py migrate --settings shimatta_kenkyusho.settings_production
|
|
||||||
|
|
||||||
python manage.py runserver 0.0.0.0:8000 --settings shimatta_kenkyusho.settings_production
|
|
@ -16,5 +16,4 @@ urlpatterns = [
|
|||||||
path('distributors/<slug:uuid>/', parts_views.DistributorDetailView.as_view(), name='parts-distributors-detail'),
|
path('distributors/<slug:uuid>/', parts_views.DistributorDetailView.as_view(), name='parts-distributors-detail'),
|
||||||
path('manufacturers/', parts_views.ManufacturersViewSet.as_view(), name='parts-manufacturers'),
|
path('manufacturers/', parts_views.ManufacturersViewSet.as_view(), name='parts-manufacturers'),
|
||||||
path("manufacturers/<slug:uuid>/", parts_views.ManufacturerDetailViewSet.as_view(), name='parts-manufacturers-detail'),
|
path("manufacturers/<slug:uuid>/", parts_views.ManufacturerDetailViewSet.as_view(), name='parts-manufacturers-detail'),
|
||||||
path("healthcheck/", parts_views.health_check_view, name='parts-health-check'),
|
|
||||||
]
|
]
|
||||||
|
@ -18,10 +18,8 @@ from .forms import *
|
|||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.db.models.functions import Lower
|
from django.db.models.functions import Lower
|
||||||
from django.forms import formset_factory
|
from django.forms import formset_factory
|
||||||
from django.http import HttpResponse
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
ParameterSearchFormSet = formset_factory(ComponentParameterSearchForm, extra=1)
|
ParameterSearchFormSet = formset_factory(ComponentParameterSearchForm, extra=1)
|
||||||
|
|
||||||
class QrSearchForm(forms.Form):
|
class QrSearchForm(forms.Form):
|
||||||
@ -955,12 +953,4 @@ class ManufacturerDetailViewSet(LoginRequiredMixin, BaseTemplateMixin, DetailVie
|
|||||||
elif 'submit-manufacturer-edit' in request.POST:
|
elif 'submit-manufacturer-edit' in request.POST:
|
||||||
return self.edit_manufacturer(request)
|
return self.edit_manufacturer(request)
|
||||||
|
|
||||||
return super().post(request, *args, **kwargs)
|
return super().post(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def health_check_view(request) -> HttpResponse:
|
|
||||||
"""
|
|
||||||
Health checking view. Returns empty http response with HTTP status OK.
|
|
||||||
This will be used to check
|
|
||||||
"""
|
|
||||||
return HttpResponse(status=200)
|
|
@ -16,13 +16,9 @@ The following environment variables have to be set:
|
|||||||
- DJANGO_MEDIA_URL
|
- DJANGO_MEDIA_URL
|
||||||
- DJANGO_MEDIA_ROOT
|
- DJANGO_MEDIA_ROOT
|
||||||
- DJANGO_POSTGRESQL_SOCKET
|
- DJANGO_POSTGRESQL_SOCKET
|
||||||
- DJANGO_POSTGRESQL_PORT
|
|
||||||
|
|
||||||
The following can be set
|
The following can be set
|
||||||
- DJANGO_POSTGRESQL_PW (assumed empty if missing)
|
|
||||||
- DJANGO_POSTGRESQL_USER (assmumed empty if mssing)
|
|
||||||
- DJANGO_SECURE_HSTS_SECONDS (defaults to 120)
|
- DJANGO_SECURE_HSTS_SECONDS (defaults to 120)
|
||||||
- DJANGO_FORCE_DEV_MODE
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -50,11 +46,8 @@ SECRET_KEY = get_env_value('DJANGO_SECRET_KEY')
|
|||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
if get_env_value('DJANGO_FORCE_DEV_MODE', default=False) == 'True':
|
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = ['localhost', get_env_value('DJANGO_ALLOWED_HOST')]
|
||||||
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', get_env_value('DJANGO_ALLOWED_HOST')]
|
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
@ -239,4 +232,4 @@ CSRF_COOKIE_SECURE = True
|
|||||||
|
|
||||||
SECURE_SSL_REDIRECT = False
|
SECURE_SSL_REDIRECT = False
|
||||||
|
|
||||||
SECURE_HSTS_SECONDS = get_env_value('DJANGO_SECURE_HSTS_SECONDS', default=120)
|
SECURE_HSTS_SECONDS = get_env_value('DJANGO_SECURE_HSTS_SECONDS', default=120)
|
@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Startup the db container
|
|
||||||
docker-compose start shimatta-kenkyusho-db
|
|
||||||
|
|
||||||
# Override entrypoint to get interactive shell
|
|
||||||
docker-compose run --entrypoint="/bin/sh" -p 8000:8000 shimatta-kenkyusho-web
|
|
Loading…
Reference in New Issue
Block a user