Skip to content

Commit 81fb234

Browse files
author
Mike Barnes
committed
Added the Caddyfile and a Dockerfile so we can containerize it and serve the app
1 parent 21ddd81 commit 81fb234

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed

Caddyfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# global options
2+
{
3+
admin off # there's no need for the admin api in railway's environment
4+
persist_config off # storage isn't persistent anyway
5+
auto_https off # railway handles https for us, this would cause issues if left enabled
6+
# runtime logs
7+
log {
8+
format json # set runtime log format to json mode
9+
}
10+
# server options
11+
servers {
12+
trusted_proxies static private_ranges 100.0.0.0/8 # trust railway's proxy
13+
}
14+
}
15+
16+
# site block, listens on the $PORT environment variable, automatically assigned by railway
17+
:{$PORT:3000} {
18+
# access logs
19+
log {
20+
format json # set access log format to json mode
21+
}
22+
23+
# health check for railway
24+
rewrite /health /*
25+
26+
# serve from the 'dist' folder (Vite builds into the 'dist' folder)
27+
root * dist
28+
29+
# enable gzipping responses
30+
encode gzip
31+
32+
# serve files from 'dist'
33+
file_server
34+
35+
# if path doesn't exist, redirect it to 'index.html' for client side routing
36+
try_files {path} /index.html
37+
}

Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Use the Node alpine official image
2+
# https://hub.docker.com/_/node
3+
FROM node:lts-alpine AS build
4+
5+
# Set config
6+
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
7+
ENV NPM_CONFIG_FUND=false
8+
9+
# Create and change to the app directory.
10+
WORKDIR /app
11+
12+
# Copy the files to the container image
13+
COPY package*.json ./
14+
15+
# Install packages
16+
RUN npm ci
17+
18+
# Copy local code to the container image.
19+
COPY . ./
20+
21+
# Build the app.
22+
RUN npm run build
23+
24+
# Use the Caddy image
25+
FROM caddy
26+
27+
# Create and change to the app directory.
28+
WORKDIR /app
29+
30+
# Copy Caddyfile to the container image.
31+
COPY Caddyfile ./
32+
33+
# Copy local code to the container image.
34+
RUN caddy fmt Caddyfile --overwrite
35+
36+
# Copy files to the container image.
37+
COPY --from=build /app/dist ./dist
38+
39+
# Use Caddy to run/serve the app
40+
CMD ["caddy", "run", "--config", "Caddyfile", "--adapter", "caddyfile"]

src/powersync/System.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ export const powerSync = new PowerSyncDatabase({
7272
await connector.signInAnonymously();
7373

7474
// Establish connection between PowerSync and the Supabase connector
75-
powerSync.connect(connector, { clientImplementation: SyncClientImplementation.RUST });
75+
powerSync.connect(connector, { clientImplementation: SyncClientImplementation.RUST });

0 commit comments

Comments
 (0)