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
Branches
No related tags found
No related merge requests found
Pipeline #418 passed
.git .git
.venv .venv
.envrc .envrc
static_files/
media_files/
...@@ -143,5 +143,5 @@ cython_debug/ ...@@ -143,5 +143,5 @@ cython_debug/
# direnv # direnv
.envrc .envrc
media/ media_files/
static/ static_files/
...@@ -3,6 +3,7 @@ image: docker:19.03.1 ...@@ -3,6 +3,7 @@ image: docker:19.03.1
variables: variables:
DOCKER_TLS_CERTDIR: "/certs" DOCKER_TLS_CERTDIR: "/certs"
IMAGE_TAG_APP: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG IMAGE_TAG_APP: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
IMAGE_TAG_NGINX: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-nginx
services: services:
- docker:19.03.1-dind - docker:19.03.1-dind
...@@ -14,4 +15,6 @@ build: ...@@ -14,4 +15,6 @@ build:
stage: build stage: build
script: script:
- docker build -t $IMAGE_TAG_APP . - docker build -t $IMAGE_TAG_APP .
- docker build -t $IMAGE_TAG_NGINX . -f Dockerfile.nginx
- docker push $IMAGE_TAG_APP - docker push $IMAGE_TAG_APP
- docker push $IMAGE_TAG_NGINX
...@@ -12,7 +12,9 @@ RUN useradd app ...@@ -12,7 +12,9 @@ RUN useradd app
RUN chown -R app /app RUN chown -R app /app
USER 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 EXPOSE 8000
......
FROM nginx
EXPOSE 8080
ADD nginx.conf /etc/nginx/conf.d/majak.conf
...@@ -137,10 +137,10 @@ STATICFILES_DIRS = [ ...@@ -137,10 +137,10 @@ STATICFILES_DIRS = [
# See https://docs.djangoproject.com/en/3.0/ref/contrib/staticfiles/#manifeststaticfilesstorage # See https://docs.djangoproject.com/en/3.0/ref/contrib/staticfiles/#manifeststaticfilesstorage
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.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/" STATIC_URL = "/static/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media") MEDIA_ROOT = os.path.join(BASE_DIR, "media_files")
MEDIA_URL = "/media/" 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