Ilyas-Codes / eCourse

A self-hosted SPA to simplify course creation and management
https://ecourse.pockethost.io
MIT License
446 stars 33 forks source link

PocketBase 404 with Dockerfile #7

Closed ImShallo closed 7 months ago

ImShallo commented 7 months ago

Description

Users experience a PocketBase 404 (Not Found) error when accessing the frontend via the designated IP address, despite the backend working properly.

Steps to Reproduce

  1. Clone the dockerfile
  2. Build and run the Docker container using the dockerfile
  3. Access the frontend using the designated IP address

Expected Behavior

Users should be able to access the frontend interface without encountering a 404 error.

Frontend View Backend View

Ilyas-Codes commented 7 months ago

my bad I forgot to add /* after the dist folder, this should work:

FROM node:20.11.1-buster

WORKDIR /

RUN git clone https://github.com/Ilyas-Codes/eCourse.git

ARG PB_VERSION=0.21.3
ADD https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip /tmp/pb.zip
RUN unzip /tmp/pb.zip -d /eCourse/pb

WORKDIR /eCourse/ui

RUN sed -i 's/^VITE_PROD_PB_URL=.*/VITE_PROD_PB_URL=http:\/\/127.0.0.1:8090/' .env
RUN npm install
RUN npm run build
RUN mv dist/* /eCourse/pb/pb_public

EXPOSE 8090

CMD ["/eCourse/pb/pocketbase", "serve", "--http=0.0.0.0:8090"]
ImShallo commented 7 months ago

my bad I forgot to add /* after the dist folder, this should work: ....

Still not working @Ilyas-Codes, idk what I am doing wrong but I tried also with docker-compose (to just use the dockerfile because there is no image of ecourse on the docker hub)

Here's the only log of the container

2024/02/28 21:26:09 Server started at http://0.0.0.0:8090
├─ REST API: http://0.0.0.0:8090/api/
└─ Admin UI: http://0.0.0.0:8090/_/

Essentially only pocketbase started (and it works)

Moreover... I've tried to run the app on my windows machine and it works perfectly

C:\Users\Administrator\Desktop\eCourse\ui>npm run dev
> ecourse@2.0.0 dev
> vite
  VITE v5.1.4  ready in 1061 ms
  ➜  Local:   http://localhost:5173/

Shouldn't the dockerfile do the same? I'm not an expert of Docker, but I think that this app should have two images: one of the backend (pocketbase) and another one for the ui (vite). Maybe you can achieve this better with docker-compose

Ilyas-Codes commented 7 months ago

weird, I just tested it and it worked fine. can you redo everything from scratch? delete the container and image and redo the build again.

Ilyas-Codes commented 7 months ago

@Orohym here are the steps I followed with docker:

  1. create a directory somewhere and name it whatever, add the Dockerfile I left in my first comment in there.
  2. run: docker build -t image-name .
  3. run: docker run -d -p 8090:8090 --name container-name image-name
  4. navigate to localhost:8090
ImShallo commented 7 months ago

@Ilyas-Codes I replicated your steps and it works.

I was still copying the Dockerfile example from the Readme file and that was the reason it was not working. (😅)

Thank you

Ilyas-Codes commented 7 months ago

Not a problem :)