Skip to content

Commit

Permalink
fix(docker): static file serving works with refresh now
Browse files Browse the repository at this point in the history
  • Loading branch information
yyewolf committed May 13, 2024
1 parent 0f8c071 commit 8d05158
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
17 changes: 13 additions & 4 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
:8080

root * /www/html
file_server
:8080 {
handle {
encode zstd gzip
try_files {path} {path}.html index.html
file_server {
pass_thru
}
}
handle {
file_server
rewrite * 200.html
}
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ RUN npm run build
FROM caddy:2.7.6-alpine

COPY Caddyfile /etc/caddy/Caddyfile
COPY --from=build /app/build /www/html
COPY --from=build /app/build /srv
3 changes: 2 additions & 1 deletion src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const prerender = true
export const prerender = true;
export const ssr = false;
4 changes: 3 additions & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const config = {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter()
adapter: adapter({
fallback: '200.html' // may differ from host to host
})
},

extensions: ['.svelte', '.svx']
Expand Down

0 comments on commit 8d05158

Please sign in to comment.