Skip to content
Snippets Groups Projects
Commit 73d85286 authored by jan.bednarik's avatar jan.bednarik
Browse files

Deployment with nginx for media files

parent 25fc0318
No related branches found
No related tags found
No related merge requests found
.git
.venv
.envrc
static_files/
media_files/
......@@ -143,5 +143,5 @@ cython_debug/
# direnv
.envrc
media/
static/
media_files/
static_files/
......@@ -3,6 +3,7 @@ image: docker:19.03.1
variables:
DOCKER_TLS_CERTDIR: "/certs"
IMAGE_TAG_APP: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
IMAGE_TAG_NGINX: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-nginx
services:
- docker:19.03.1-dind
......@@ -14,4 +15,6 @@ build:
stage: build
script:
- docker build -t $IMAGE_TAG_APP .
- docker build -t $IMAGE_TAG_NGINX . -f Dockerfile.nginx
- docker push $IMAGE_TAG_APP
- docker push $IMAGE_TAG_NGINX
......@@ -12,7 +12,9 @@ RUN useradd app
RUN chown -R app /app
USER app
ENV DJANGO_SETTINGS_MODULE "majak.settings.production"
# TODO HACK!
# ENV DJANGO_SETTINGS_MODULE "majak.settings.production"
ENV DJANGO_SETTINGS_MODULE "majak.settings.dev"
EXPOSE 8000
......
FROM nginx
EXPOSE 8080
ADD nginx.conf /etc/nginx/conf.d/majak.conf
......@@ -137,10 +137,10 @@ STATICFILES_DIRS = [
# See https://docs.djangoproject.com/en/3.0/ref/contrib/staticfiles/#manifeststaticfilesstorage
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_ROOT = os.path.join(BASE_DIR, "static_files")
STATIC_URL = "/static/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_ROOT = os.path.join(BASE_DIR, "media_files")
MEDIA_URL = "/media/"
......
upstream majak {
ip_hash;
server app:8000;
}
server {
server_name majak;
listen 8080;
client_max_body_size 10M;
location /media/ {
alias /var/opt/majak/media_files/;
}
location / {
proxy_pass http://majak/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment