Skip to content

Commit

Permalink
feat: serving static files
Browse files Browse the repository at this point in the history
  • Loading branch information
riipandi committed Feb 17, 2024
1 parent 92075ec commit caaa133
Show file tree
Hide file tree
Showing 11 changed files with 424 additions and 92 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ ENV HUSKY 0
# -----------------------------------------------------------------------------
FROM base AS builder
COPY --chown=node:node . .
RUN --mount=type=cache,id=cache-pnpm,target=/pnpm/store pnpm install && pnpm build
RUN --mount=type=cache,id=cache-pnpm,target=/pnpm/store pnpm install
RUN --mount=type=cache,id=cache-pnpm,target=/pnpm/store NODE_ENV=production pnpm build

# -----------------------------------------------------------------------------
# Build the application
Expand All @@ -30,6 +31,7 @@ WORKDIR /srv
COPY --from=builder /srv/package.json ./package.json
COPY --from=builder /srv/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /srv/.npmrc ./.npmrc
COPY --from=builder /srv/public ./public
COPY --from=builder /srv/dist ./dist

# Install production dependencies
Expand Down Expand Up @@ -73,4 +75,4 @@ ENV PORT 3080
EXPOSE 3080

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/usr/local/bin/node", "dist/server.cjs"]
CMD ["/usr/local/bin/node", "dist/server.mjs"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ See the [license file](./LICENSE) for more information.

- [SQLite tutorials](https://www.sqlitetutorial.net)
- [LibSQL extensions documentation](https://docs.turso.tech/extensions)
- [Understanding SQLite Transaction](https://www.sql-easy.com/learn/sqlite-transaction)
- [Local development with LibSQL](https://docs.turso.tech/local-development)
- [OWASP Authentication Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html)
---
Expand Down
4 changes: 2 additions & 2 deletions build.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ await build({
outdir: "dist",
target: ["node20"],
platform: "node",
format: "cjs",
format: "esm",
bundle: true,
sourcemap: false,
allowOverwrite: true,
outExtension: { ".js": ".cjs" },
outExtension: { ".js": ".mjs" },
minify: process.env.NODE_ENV === "production",
drop: ["console", "debugger"],
loader: { ".ts": "ts" },
Expand Down
2 changes: 1 addition & 1 deletion fly.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ console_command = "/bin/sh"

[deploy]
strategy = "immediate"
# release_command = "/usr/local/bin/node dist/migrate.cjs migrate"
# release_command = "/usr/local/bin/node dist/migrate.mjs migrate"

[env]
BIND_ADDR = "0.0.0.0:3080"
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scripts": {
"build": "wireit",
"dev": "tsx watch src/server.ts",
"start": "node dist/server.cjs",
"start": "node dist/server.mjs",
"docs:dev": "(cd docs && mintlify dev)",
"docs:check": "(cd docs && mintlify broken-links)",
"db:migrate": "tsx src/migrate.ts",
Expand Down Expand Up @@ -45,23 +45,24 @@
}
},
"dependencies": {
"@hono/node-server": "^1.7.0",
"@hono/valibot-validator": "^0.2.1",
"@libsql/client": "^0.4.3",
"@hono/node-server": "^1.8.0",
"@hono/valibot-validator": "^0.2.2",
"@libsql/client": "^0.5.0",
"@libsql/kysely-libsql": "^0.3.0",
"arctic": "^1.1.6",
"consola": "^3.2.3",
"dotenv": "^16.4.3",
"hono": "^4.0.1",
"dotenv": "^16.4.4",
"hono": "^4.0.3",
"kysely": "^0.27.2",
"oslo": "^1.1.1",
"typeid-js": "^0.5.0",
"valibot": "^0.28.1"
},
"devDependencies": {
"@biomejs/biome": "^1.5.3",
"@types/node": "^20.11.17",
"@types/node": "^20.11.19",
"esbuild": "^0.20.0",
"husky": "^9.0.10",
"husky": "^9.0.11",
"mintlify": "^4.0.125",
"npm-check-updates": "^16.14.15",
"rimraf": "^5.0.5",
Expand Down
Loading

0 comments on commit caaa133

Please sign in to comment.