Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

sveltekit adapter-node docker volume issue serving updated static files after build time

$
0
0

I work on a sveltekit app which is run in docker in production environment.

I need to serve some "static" files uploaded from another server to production server and serve them from my app. Ok, they are not so static because they can change and are not in place at build time!

I thought it would be obvious to create a docker volume between host static folder and /app/static in node container. But I get a 404 error when accessing files in static folder when those were not in this folder at build time.

Here is my docker-compose.yaml not working:

version: '3.3'services:  mymy:    image: 3151/mymy    build:      context: .      dockerfile: ./Dockerfile    ports:      - '${APP_PORT}:3000'    restart: always    networks:      net1:        ipv4_address: ${MY_IPV4_ADDRESS}    volumes:      - ./static:/app/staticnetworks:  net1:    name: ${DB_NETWORK_NAME}    external: true

See what I tried in volumes section.

Here is the Dockerfile by the way:

FROM node:lts-slimWORKDIR /appCOPY ./package.json package.jsonCOPY ./package-lock.json package-lock.jsonCOPY ./src src# COPY ./static staticCOPY ./svelte.config.js svelte.config.jsCOPY ./tsconfig.json ./.svelte-kit/tsconfig.jsonCOPY ./vite.config.ts vite.config.tsCOPY ./.env .envRUN npm ciRUN npm run buildEXPOSE 3000CMD [ "node", "build" ]

I commented out COPY ./static static since I wanted it to be a docker volume.

When I launch docker-compose up --build, this url works fine:http://10.5.0.72:3000/robots.txt

(robots.txt is in static folder at build time.)

If I add test.txt in static folder when app is running,http://10.5.0.72:3000/test.txt returns a 404...

All I need is an idea to rsync files from outside my app and serve them.

I'm stuck for hours now... Any help?

Kind regards.


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>