[TOOL IMPROVEMENT] Dockerfile with subfolder url
FROM node:lts-alpine AS build
ARG TOOLZ_REPO="https://github.com/CorentinTh/it-tools.git"
RUN apk add --no-cache git \
&& rm -rf /var/cache/apk/*
WORKDIR /app
RUN git clone ${TOOLZ_REPO} toolz
WORKDIR /app/toolz
# make sub url
ARG SUB_URL=
RUN if [[ -n "$SUB_URL" ]] \
; then \
sed -i -e "s|href=\"/|href=\"|" index.html \
&& sed -i -e "s|src: \'/|src: \'|" vite.config.ts \
&& sed -i -e "s|routes:|base: config.app.baseUrl, routes:|" src/router.ts \
&& sed -i -e "s|resolve:|base: process.env.SUB_URL + '/', resolve:|" vite.config.ts \
&& sed -i -e "s|default: '/',|default: process.env.SUB_URL,|" src/config.ts \
&& sed -i -e "s|start_url: '/?utm_source=pwa&utm_medium=pwa',|start_url: process.env.SUB_URL + '/?utm_source=pwa\&utm_medium=pwa',|" vite.config.ts \
; fi
# compile
RUN npm install -g pnpm \
&& pnpm i --frozen-lockfile \
&& pnpm build
FROM nginx:stable-alpine AS production
COPY --from=build /app/toolz/dist /usr/share/nginx/html
COPY --from=build /app/toolz/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
change arg SUB_URL to need subfolder
ex: ARG SUB_URL=/sub for http://domain.org/sub/
build image:
docker build -t it-tools:mode /folder_with_dockerfile/. -f /folder_with_dockerfile/Dockerfile
@CorentinTh Do you plan to add this excellent option in the it-tools code?
Hi @DeAlexPesh and @cvc90 , implemented in my fork, if you arr interested in up to date version of it-tools, I made kind of a fork here : https://github.com/sharevb/it-tools (https://sharevb-it-tools.vercel.app/ and docker images https://github.com/sharevb/it-tools/pkgs/container/it-tools)
Hi @DeAlexPesh and @cvc90 , implemented in my fork, if you arr interested in up to date version of it-tools, I made kind of a fork here : sharevb/it-tools (sharevb-it-tools.vercel.app and docker images sharevb/it-tools/pkgs/container/it-tools)
Thanks, I'll check it out! 😄
UPDATE: The new features are interesting, but it still doesn't have the direct possibility of indicating the base path in a subfolder when creating Docker, it is not possible to use it through Dockerfile if you want to use Watchdog for Docker, if so, could you tell me how to use it?
Hi @cvc90, it should work with the procedure here : https://github.com/sharevb/it-tools?tab=readme-ov-file#build-docker-image-for-a-subfolder ; subfolder must be set at docker build time (not at runtime)
Hi @cvc90, it should work with the procedure here : sharevb/it-tools#build-docker-image-for-a-subfolder ; subfolder must be set at docker build time (not at runtime)
Hi @sharevb,
As I mentioned, this method doesn't work for me with Watchdog, for it to work, it must be done without a Dockerfile.
The section you're referring to has a URL to a comment that doesn't work.
Thanks
Hi @cvc90 , I will try to release a docker image with "/it-tools/" as BASE_URL
Hi @DeAlexPesh , @cvc90 , implemented BASE_URL (and config sample) in my fork, and published a baseurl-it-tools tag
Detailed explaination: https://github.com/sharevb/it-tools?tab=readme-ov-file#docker-compose-for-hosting-in-a-it-tools-subfolder and https://github.com/sharevb/it-tools?tab=readme-ov-file#docker-compose-for-hosting-in-a-it-tools-subfolder
Hi @sharevb.
I'm trying what you mentioned, but it doesn't seem to work
The nginx example is not correct
Current Nginx example (nginx.conf)
server {
listen 8080;
server_name _;
location /it-tools/ {
proxy_pass http://it-tools-subfolder:8080/;
}
}
Fixed Nginx example
server {
listen 8080;
server_name _;
location /it-tools/ {
proxy_pass http://it-tools-subfolder:8080/it-tools/;
}
}
When trying to access http://it-tools-subfolder-server:8080/it-tools/, it doesn't load, I get a blank screen.
When trying to access http://it-tools-subfolder-server/it-tools/, it doesn't load, I get a blank screen.
I'm getting 400 errors in the log
The normal version works correctly but it is not possible to perform the reverse proxy function
Any idea why this error occurs?
Hi @cvc90 , may be I need to clarify in README : it-tools-subfolder is internal server. With my sample in https://github.com/sharevb/it-tools/tree/chore/all-my-stuffs/docker-subfolder-sample, you need to access http://localhost:8080/it-tools/ (that is the reverse proxy). This is the only address that works.
Hi @sharevb,
I can't get it to work.
Could you check that the Docker version is working correctly?
I can access the normal version perfectly.
When I access the Docker version directly through the Docker port http://localhost:8080/it-tools/, the screen loads but goes blank and displays these loading errors.
When I access the Docker version directly through the reverse proxy http://localhost/it-tools/, the screen loads but goes blank and displays these loading errors.
I think that the error comes from the “special” docker that does not do correctly the url redirection or some problem with the mime type of the Nginx server.
I have many other services running this way without any issues.
Hi @cvc90 , I tested with Docker Desktop and WSL2, using docker compose up from https://github.com/sharevb/it-tools/tree/chore/all-my-stuffs/docker-subfolder-sample using procedure here : https://github.com/sharevb/it-tools/tree/chore/all-my-stuffs?tab=readme-ov-file#docker-compose-for-hosting-in-a-it-tools-subfolder
And http://localhost:8080/it-tools/ respond correctly
I cannot reproduce these strange errors text/html.