Hi, quick question, I used caddy before with my local setup (not inside docker) and it worked fine!
Now i am trying to run it via docker but i am getting this error:
GET http://localhost:8888/ui/app NOT FOUND
It seems like it cant find it? Going to / or /hello works correctly and responds correctly. So it seems like an issue in finding the root directory?
I bashed into my container and my frontend files are definitely located at
/srv/index.html
/srv/favicon.ico
etc…
Caddyfile:
:80 {
handle_path /ui/app* {
root * /srv
file_server
try_files {path} /index.html
}
handle {
respond "not found" 404
}
handle / {
respond "index" 200
}
handle /hello {
respond "hello" 200
}
}
My docker file:
FROM node:13.12.0-alpine as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm ci --silent
RUN npm install react-scripts@3.4.1 -g --silent
COPY . ./
RUN npm run build
FROM caddy:2.1.1-alpine
COPY Caddyfile /etc/caddy/Caddyfile
COPY build /srv
EXPOSE 80
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
I was hoping for a quick and simple fix, because this setup works when i run it locally outside of docker.
EDIT: I made it work using nginx with this configuration:
server {
listen 80;
location = /ui/app {
root /srv;
try_files /index.html =404;
}
location ~ ^/ui/app(.*) {
root /srv;
try_files $1 $1/ /index.html =404;
}
}