Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename not working as expected #80

Open
enboig opened this issue Dec 18, 2022 · 4 comments
Open

rename not working as expected #80

enboig opened this issue Dec 18, 2022 · 4 comments

Comments

@enboig
Copy link

enboig commented Dec 18, 2022

I renamed containers name in .env and when I run make rename they aren't renamed in docker-compose.yml. I renamed them manually in docker-compose.yml but then if I run make rename they are overwrite.
Could it be that .env is not used?

Reading Makefile file it appear it is using librephotos.env and not .env

@phockett
Copy link

I just ran into this too - to fix, just change the third line of the Makefile:

include librephotos.env

The default case is include librephotos.env.

To run with your own file, just change the name as required, e.g. change to include .env to use your current .env file for the renaming.

@phockett
Copy link

phockett commented Dec 30, 2023

Actually, after fixing the above, I now have other issues:

  1. Proxy fails due to renamed frontend container. I fixed this by manually changing the nginx.conf file (has hard-coded frontend and backend names) and rebuilding the proxy container locally.

File:
https://github.com/LibrePhotos/librephotos-docker/blob/main/proxy/nginx.conf

Rebuild with: docker build -t proxy_archive --no-cache . from the /proxy directory to push local changes to the build. (Also the main docker-compose.yml file needs to be modified to use this local image, rather than the main repository image, change image: reallibrephotos/librephotos-proxy:${tag} to image: proxy_archive, at

image: reallibrephotos/librephotos-proxy:${tag}
).

  1. I now am stuck with Nginx config settings, which are giving problems with the ALLOWED_HOST, which also seems to be expecting backend as the container name (my container is currently called backend_archive).

Error in logs:

backend_archive   | django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'backend'. You may need to add 'backend' to ALLOWED_HOSTS.

This should be set from the ENV settings I think, see https://github.com/LibrePhotos/librephotos/blob/04ac679400c9424d122bd1d71f4012423526b3b3/librephotos/settings/production.py#L48

In the main docker-compose.yml this should be configured:

    environment:
      - BACKEND_HOST=backend_archive

... but doesn't seem to be working for me at the moment. I'm now troubleshooting to see if I can find out where the issue is.

@phockett
Copy link

phockett commented Jun 20, 2024 via email

@itribs
Copy link

itribs commented Sep 16, 2024

I borrowed the 'proxy' directory and used the following to solve the problem:

  1. edit the 'Makefile' file and add the following to 'rename':
$(REPLACE_NAMES) proxy/nginx.raw > proxy/nginx.conf
  1. edit the 'docker-compose.raw' file, replacing 'image: reallibrephotos/librephotos-proxy:${tag}'
build:
      context: ./proxy
      args:
        tag: ${tag}
  1. create 'proxy/nginx.raw' and replace all 'frontend' and 'backend' in the default 'nginx.conf' with 'frontend__name', 'backend__name', the final content is as follows:
user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log debug;

events {
    worker_connections  1024;
}

http {
  server {
    listen 80;

    location / {
      # React routes are entirely on the App side in the web browser
      # Always proxy to root with the same page request when nginx 404s
      error_page 404 /;
      proxy_intercept_errors on;
      proxy_set_header Host $host;
      proxy_pass http://__frontend_name__:3000/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }
    # Allow to download zip files directly. This has to go before the following rule
    location ~ ^/api/downloads/(.*)$ {
      root /;
      try_files /protected_media/zip/$1.zip =404;
    }
    location ~ ^/(api|media)/ {
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host __backend_name__;
      include uwsgi_params;
      proxy_pass http://__backend_name__:8001;
    }
    # needed for webpack-dev-server
    location /ws {
      proxy_pass http://__frontend_name__:3000;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }
    # Django media
    location /protected_media  {
        internal;
        alias /protected_media/;
    }

    location /static/drf-yasg {
        proxy_pass http://__backend_name__:8001;
    }

    location /data  {
        internal;
        alias /data/;
    }

    # Original Photos
    location /original  {
        internal;
        alias /data/;
    }
    # Nextcloud Original Photos
    location /nextcloud_original  {
        internal;
        alias /data/nextcloud_media/;
    }
  }
}
  1. edit 'Dockerfile'
ARG tag
FROM reallibrephotos/librephotos-proxy:${tag}
COPY nginx.conf /etc/nginx/nginx.conf
  1. runsudo docker compose up --build -d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants