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

NEXT_PUBLIC_API_URL not used when using pre-built Docker images #460

Closed
meb427 opened this issue Nov 10, 2024 · 4 comments
Closed

NEXT_PUBLIC_API_URL not used when using pre-built Docker images #460

meb427 opened this issue Nov 10, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@meb427
Copy link

meb427 commented Nov 10, 2024

Describe the bug
Using pre-built images for docker-front env variable can't be overriden.
itzcrazykns1337/perplexica-frontend:main

To Reproduce

Docker compose setup:

perplexica-frontend:
image: itzcrazykns1337/perplexica-frontend:main
container_name: perplexica-frontend
environment:
- NEXT_PUBLIC_API_URL=https://perplexica-back.MYDOMAIN/api
- NEXT_PUBLIC_WS_URL=wss://perplexica-back.MYDOMAIN
depends_on:
- perplexica-backend
volumes:
- ./perplexica-config.toml:/home/perplexica/config.toml
ports:
- 3980:3000
restart: unless-stopped

Chrome console
GET http://127.0.0.1:3001/api/models net::ERR_CONNECTION_REFUSED

Checking in container I See the env correctly set

/home/perplexica # env
NODE_VERSION=23.1.0
HOSTNAME=ebf749acf153
YARN_VERSION=1.22.22
SHLVL=1
HOME=/root
TERM=xterm-256color
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NEXT_PUBLIC_WS_URL=wss://perplexica-back.MYDOMAIN
LANG=C.UTF-8
NEXT_PUBLIC_API_URL=https://perplexica-back.MYDOMAIN/api
LC_ALL=C.UTF-8
PWD=/home/perplexica
/home/perplexica #

Expected behavior
ENV used if added in docker-compose.

Screenshots
N/A

Additional context
Ability to setup perplexica in remote servers and not rely on 127.0.0.1:3001 that seem hard coded or can't be overriden in pre-build images: itzcrazykns1337/perplexica-frontend:main

@meb427 meb427 added the bug Something isn't working label Nov 10, 2024
@meb427 meb427 changed the title Docker NEXT_PUBLIC_API_URL not use when using pre-built Docker images Nov 10, 2024
@meb427 meb427 changed the title NEXT_PUBLIC_API_URL not use when using pre-built Docker images NEXT_PUBLIC_API_URL not used when using pre-built Docker images Nov 10, 2024
@Deathproof76
Copy link

Deathproof76 commented Nov 13, 2024

Can confirm.
When I build the frontend image with a local ip instead of 127.0.0.1:3001 (for example):

    build:
      context: .
      dockerfile: app.dockerfile
      args:
        - NEXT_PUBLIC_API_URL=http://192.168.0.208:3001/api
        - NEXT_PUBLIC_WS_URL=ws://192.168.0.208:3001

I'm able to use perplexica from another device in my lan. If I only change the env while using the prebuilt image or build with 127.0.0.1:3001 as arg, it throws the same error as op.

Most likely something that happened since v1.9.0-rc. I had a similar issue and used a different prebuilt image which was based on an older built #142 (comment) .

Edit: the working built was [email protected]

@alexandrekm
Copy link

I can confirm that the same issue happens to me.

@timoa
Copy link

timoa commented Nov 15, 2024

I worked on rewriting the Docker images (reducing their size by -65% and securing them) and also fixed the issue with the ENV vars so that they can be used without rebuilding the Docker images.

It uses the .env file outside the Docker image. The .env is loaded now by Docker compose instead of the Docker build time.

The PR is here: #465.

I did this PR because I'm working on the Helm Chart to deploy Perplexica on Kubernetes, and I had this issue with the official Docker images.

@ItzCrazyKns
Copy link
Owner

Please refer to: #388

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants