mirror of
https://github.com/olegvodyanov/instalinks.git
synced 2025-12-20 05:47:03 +03:00
change location
This commit is contained in:
parent
7261dfaed7
commit
0d66a33243
2
.gitignore
vendored
2
.gitignore
vendored
@ -14,3 +14,5 @@ __pycache__/
|
|||||||
|
|
||||||
**/migrations/
|
**/migrations/
|
||||||
!*/migrations/__init__.py # Keep the init file if you ignore migrations
|
!*/migrations/__init__.py # Keep the init file if you ignore migrations
|
||||||
|
instalinks/myapp.log
|
||||||
|
myapp.log
|
||||||
@ -6,20 +6,30 @@ FROM python:3.12.9-slim-bookworm
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy requirements first, to leverage Docker's layer caching
|
# Copy requirements first, to leverage Docker's layer caching
|
||||||
COPY instalinks/requirements.txt /app/
|
COPY instalinks/instalinks/requirements.txt /app/
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt && \
|
||||||
|
apt update && apt install -y nginx uwsgi which gcc
|
||||||
|
|
||||||
# Copy the rest of the source code
|
# Copy the rest of the source code
|
||||||
COPY instalinks/ /app/
|
COPY instalinks/ /app/
|
||||||
|
COPY static /app/static
|
||||||
|
COPY nginx/etc/nginx/sites-available /etc/nginx/sites-available
|
||||||
|
COPY running.sh /app/
|
||||||
|
COPY manage.py /app/
|
||||||
|
|
||||||
|
ENV DB_USER=/run/secrets/DB_USER
|
||||||
|
ENV DB_PASSWORD=/run/secrets/DB_PASSWORD
|
||||||
|
ENV DB_NAME=/run/secrets/DB_NAME
|
||||||
|
|
||||||
# Set environment variables for Django
|
# Set environment variables for Django
|
||||||
ENV PYTHONUNBUFFERED 1
|
ENV PYTHONUNBUFFERED 1
|
||||||
ENV DJANGO_SETTINGS_MODULE instagram_links.settings
|
ENV DJANGO_SETTINGS_MODULE settings
|
||||||
|
|
||||||
# Expose the port Django runs on
|
# Expose the port Django runs on
|
||||||
EXPOSE 8000
|
# EXPOSE 8000
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
# Default command: run the Django dev server
|
# Default command: run the Django dev server
|
||||||
CMD ["gunicorn", "instalinks.wsgi:application"]
|
CMD /app/running.sh
|
||||||
@ -4,9 +4,9 @@
|
|||||||
FROM bitnami/postgresql:17.4.0-debian-12-r12
|
FROM bitnami/postgresql:17.4.0-debian-12-r12
|
||||||
|
|
||||||
# Set environment variables to override default credentials
|
# Set environment variables to override default credentials
|
||||||
ENV POSTGRES_USER=/run/secrets/DB_USER
|
#ENV POSTGRES_USER=DB_USER
|
||||||
ENV POSTGRES_PASSWORD=/run/secrets/DB_PASSWORD
|
#ENV POSTGRES_PASSWORD=DB_PASSWORD
|
||||||
ENV POSTGRES_DB=/run/secrets/DB_NAME
|
#ENV POSTGRES_DB=DB_NAME
|
||||||
|
|
||||||
# Copy the SQL init script into the entrypoint directory
|
# Copy the SQL init script into the entrypoint directory
|
||||||
COPY init.sql /docker-entrypoint-initdb.d/init.sql
|
COPY init.sql /docker-entrypoint-initdb.d/init.sql
|
||||||
|
|||||||
@ -11,6 +11,6 @@ import os
|
|||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'instalinks.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'asettings')
|
||||||
|
|
||||||
application = get_asgi_application()
|
application = get_asgi_application()
|
||||||
@ -63,6 +63,6 @@
|
|||||||
<!-- Bootstrap JS -->
|
<!-- Bootstrap JS -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
<!-- Custom JS -->
|
<!-- Custom JS -->
|
||||||
<script src="{% static "links/main.js" %}"></script>
|
<script src="{% static 'links/main.js' %}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -27,7 +27,7 @@ SECRET_KEY = 'django-insecure--6^d01urjvdon#5(lf+-1qm385!$82j^q@6*&=xkm^0f@0s(h-
|
|||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = []
|
ALLOWED_HOSTS = ['.localhost', '127.0.0.1', '[::1]']
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
@ -52,7 +52,7 @@ MIDDLEWARE = [
|
|||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'instalinks.urls'
|
ROOT_URLCONF = 'urls'
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
@ -69,10 +69,19 @@ TEMPLATES = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{
|
||||||
|
"default": {
|
||||||
|
"BACKEND": "django.core.files.storage.FileSystemStorage",
|
||||||
|
},
|
||||||
|
"staticfiles": {
|
||||||
|
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
SETTINGS_PATH = os.path.normpath(os.path.dirname(__file__))
|
SETTINGS_PATH = os.path.normpath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
||||||
WSGI_APPLICATION = 'instalinks.wsgi.application'
|
WSGI_APPLICATION = 'wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
@ -84,7 +93,7 @@ DATABASES = {
|
|||||||
'NAME': os.environ.get('DB_NAME'),
|
'NAME': os.environ.get('DB_NAME'),
|
||||||
'USER': os.environ.get('DB_USER'),
|
'USER': os.environ.get('DB_USER'),
|
||||||
'PASSWORD': os.environ.get('DB_PASSWORD'),
|
'PASSWORD': os.environ.get('DB_PASSWORD'),
|
||||||
'HOST': 'localhost',
|
'HOST': 'instagram_links_db',
|
||||||
'PORT': '5432',
|
'PORT': '5432',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,11 +133,14 @@ USE_TZ = True
|
|||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/5.2/howto/static-files/
|
# https://docs.djangoproject.com/en/5.2/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = 'static/'
|
||||||
STATICFILES_DIRS = [
|
STATICFILES_DIRS = [
|
||||||
os.path.join(BASE_DIR, 'static')
|
os.path.join(BASE_DIR, 'app/static')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
STATIC_ROOT = os.path.join(BASE_DIR, 'staticFiles')
|
||||||
|
|
||||||
|
|
||||||
# Default primary key field type
|
# Default primary key field type
|
||||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
|
||||||
|
|
||||||
@ -10,7 +10,13 @@ https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
from settings import BASE_DIR
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'instalinks.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
|
||||||
|
|
||||||
|
logging.basicConfig(filename='myapp.log', level=logging.INFO)
|
||||||
|
logger.info(f'BASE_DIR {BASE_DIR}')
|
||||||
|
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
||||||
@ -6,7 +6,7 @@ import sys
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Run administrative tasks."""
|
"""Run administrative tasks."""
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'instalinks.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
|
||||||
try:
|
try:
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
16
nginx/etc/nginx/sites-available/default
Normal file
16
nginx/etc/nginx/sites-available/default
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
server {
|
||||||
|
listen 8080;
|
||||||
|
server_name myinstalinks.ru;
|
||||||
|
access_log /var/log/nginx/instalinks-acces.log;
|
||||||
|
error_log /var/log/nginx/instalinks-error.log;
|
||||||
|
|
||||||
|
location /static/ {
|
||||||
|
alias /staticFiles/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:8000;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,14 +0,0 @@
|
|||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name instalinks.ru;
|
|
||||||
|
|
||||||
location = /favicon.ico { access_log off; log_not_found off; }
|
|
||||||
location /static/ {
|
|
||||||
root /home/youruser/myproject;
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
|
||||||
include proxy_params;
|
|
||||||
proxy_pass http://<>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
3
running.sh
Executable file
3
running.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
python manage.py collectstatic && service nginx start && gunicorn wsgi:application
|
||||||
Loading…
x
Reference in New Issue
Block a user