tangled
alpha
login
or
join now
xan.lol
/
wisp.place-monorepo
forked from
nekomimi.pet/wisp.place-monorepo
0
fork
atom
Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol.
0
fork
atom
overview
issues
pulls
pipelines
eh
nekomimi.pet
2 months ago
61216fc9
c0dad04d
+55
-10
2 changed files
expand all
collapse all
unified
split
Dockerfile
apps
main-app
src
index.ts
+47
-8
Dockerfile
···
1
1
# Production stage
2
2
-
FROM oven/bun:1.3
2
2
+
FROM oven/bun:1 AS build
3
3
4
4
WORKDIR /app
5
5
6
6
# Copy workspace configuration
7
7
-
COPY package.json bunfig.toml tsconfig.json bun.lock* ./
7
7
+
COPY package.json package.json
8
8
+
COPY bun.lock bun.lock
9
9
+
COPY bunfig.toml bunfig.toml
10
10
+
COPY tsconfig.json tsconfig.json
8
11
9
12
# Copy all workspace package.json files first (for dependency resolution)
10
13
COPY packages/@wisp/atproto-utils/package.json ./packages/@wisp/atproto-utils/package.json
···
18
21
COPY apps/hosting-service/package.json ./apps/hosting-service/package.json
19
22
20
23
# Install dependencies
21
21
-
RUN bun install --frozen-lockfile --production
24
24
+
RUN bun install
22
25
23
26
# Copy workspace source files
24
27
COPY packages ./packages
28
28
+
COPY apps/main-app ./apps/main-app
25
29
26
26
-
# Copy app source and public files
27
27
-
COPY apps/main-app ./apps/main-app
30
30
+
ENV NODE_ENV=production
31
31
+
32
32
+
# Build Tailwind CSS (build to temp files then replace originals)
33
33
+
RUN bunx @tailwindcss/cli -i ./apps/main-app/public/styles/global.css -o ./apps/main-app/public/styles/global.tmp.css --minify && \
34
34
+
mv ./apps/main-app/public/styles/global.tmp.css ./apps/main-app/public/styles/global.css
35
35
+
RUN bunx @tailwindcss/cli -i ./apps/main-app/public/admin/styles.css -o ./apps/main-app/public/admin/styles.tmp.css --minify && \
36
36
+
mv ./apps/main-app/public/admin/styles.tmp.css ./apps/main-app/public/admin/styles.css
37
37
+
38
38
+
# Build frontend (transpile all .tsx entry points to .js)
39
39
+
RUN bun build ./apps/main-app/public/index.tsx --outdir ./apps/main-app/public --target browser
40
40
+
RUN bun build ./apps/main-app/public/admin/admin.tsx --outdir ./apps/main-app/public/admin --target browser
41
41
+
RUN bun build ./apps/main-app/public/acceptable-use/acceptable-use.tsx --outdir ./apps/main-app/public/acceptable-use --target browser
42
42
+
RUN bun build ./apps/main-app/public/editor/editor.tsx --outdir ./apps/main-app/public/editor --target browser
43
43
+
RUN bun build ./apps/main-app/public/onboarding/onboarding.tsx --outdir ./apps/main-app/public/onboarding --target browser
44
44
+
45
45
+
# Update HTML files to reference .js instead of .tsx
46
46
+
RUN sed -i 's/\.tsx"/.js"/g' ./apps/main-app/public/index.html
47
47
+
RUN sed -i 's/\.tsx"/.js"/g' ./apps/main-app/public/admin/index.html
48
48
+
RUN sed -i 's/\.tsx"/.js"/g' ./apps/main-app/public/acceptable-use/index.html
49
49
+
RUN sed -i 's/\.tsx"/.js"/g' ./apps/main-app/public/editor/index.html
50
50
+
RUN sed -i 's/\.tsx"/.js"/g' ./apps/main-app/public/onboarding/index.html
51
51
+
52
52
+
# Build backend as compiled binary
53
53
+
RUN bun build \
54
54
+
--compile \
55
55
+
--target=bun \
56
56
+
--minify-whitespace \
57
57
+
--minify-syntax \
58
58
+
--outfile server \
59
59
+
./apps/main-app/src/index.ts
60
60
+
61
61
+
FROM gcr.io/distroless/base
62
62
+
63
63
+
WORKDIR /app
64
64
+
65
65
+
COPY --from=build /app/server server
66
66
+
COPY --from=build /app/apps/main-app/public /app/apps/main-app/public
28
67
29
29
-
ENV PORT=8000
68
68
+
ENV NODE_ENV=production
30
69
31
31
-
EXPOSE 8000
70
70
+
CMD ["./server"]
32
71
33
33
-
CMD ["bun", "run", "apps/main-app/src/index.ts"]
72
72
+
EXPOSE 8000
+8
-2
apps/main-app/src/index.ts
···
1
1
+
// Fix for Elysia issue with Bun, (see https://github.com/oven-sh/bun/issues/12161)
2
2
+
process.getBuiltinModule = require;
3
3
+
1
4
import { Elysia } from 'elysia'
2
5
import type { Context } from 'elysia'
3
6
import { cors } from '@elysiajs/cors'
···
127
130
.use(
128
131
await staticPlugin({
129
132
assets: './apps/main-app/public',
130
130
-
prefix: '/',
133
133
+
prefix: '/'
131
134
})
132
135
)
133
136
.get('/client-metadata.json', () => {
···
200
203
exposeHeaders: ['Content-Type'],
201
204
maxAge: 86400 // 24 hours
202
205
}))
203
203
-
.listen(8000)
206
206
+
.listen({
207
207
+
port: 8000,
208
208
+
hostname: '0.0.0.0'
209
209
+
})
204
210
205
211
console.log(
206
212
`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`