LibrePhotos / librephotos-docker

You can find here the Dockerfiles for the automated build process of LibrePhotos.
MIT License
149 stars 101 forks source link

rename not working as expected #80

Open enboig opened 1 year ago

enboig commented 1 year ago

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 commented 8 months ago

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

https://github.com/LibrePhotos/librephotos-docker/blob/01a4565ac8b1eee189438c3159776f1ad563daf6/Makefile#L3

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 commented 8 months ago

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 https://github.com/LibrePhotos/librephotos-docker/blob/01a4565ac8b1eee189438c3159776f1ad563daf6/docker-compose.yml#L13).

  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 commented 3 months ago

Nope, I never got it working correctly - I ended up just giving up on running multiple stacks, and just used multiple logins instead (although this has different issues!) :shrug:.

On Tue, Jun 18, 2024 at 11:12 AM rjdodd00 @.***> wrote:

I know this is old, but did this ever get resolved? I am having the same problem but on a fresh install

— Reply to this email directly, view it on GitHub https://github.com/LibrePhotos/librephotos-docker/issues/80#issuecomment-2176351382, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABB5Z2WOITPRI6BS5NBA6OLZIBE7HAVCNFSM6AAAAAATCXPS2OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZWGM2TCMZYGI . You are receiving this because you commented.Message ID: @.***>

itribs commented 4 days ago

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
  2. edit the 'docker-compose.raw' file, replacing 'image: reallibrephotos/librephotos-proxy:${tag}'
    build:
      context: ./proxy
      args:
        tag: ${tag}
  3. create 'proxy/nginx.raw' and replace all 'frontend' and 'backend' in the default 'nginx.conf' with 'frontendname', 'backendname', 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/;
}

} }

4. edit 'Dockerfile'

ARG tag FROM reallibrephotos/librephotos-proxy:${tag} COPY nginx.conf /etc/nginx/nginx.conf


5. run`sudo docker compose up --build -d`