-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6456a25
commit 86d0e29
Showing
10 changed files
with
182 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
node_modules | ||
dist | ||
.wrangler | ||
.dev.vars | ||
.hono | ||
|
||
# Change them to your taste: | ||
wrangler.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# syntax = docker/dockerfile:1 | ||
|
||
# Adjust NODE_VERSION as desired | ||
ARG NODE_VERSION=19.7.0 | ||
FROM node:${NODE_VERSION}-slim as base | ||
|
||
LABEL fly_launch_runtime="Vite" | ||
|
||
# Vite app lives here | ||
WORKDIR /app | ||
|
||
# Set production environment | ||
ENV NODE_ENV="production" | ||
|
||
# Install pnpm | ||
ARG PNPM_VERSION=8.6.3 | ||
RUN npm install -g pnpm@$PNPM_VERSION | ||
|
||
|
||
# Throw-away build stage to reduce size of final image | ||
FROM base as build | ||
|
||
# Install packages needed to build node modules | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 | ||
|
||
# Install node modules | ||
COPY --link package.json pnpm-lock.yaml ./ | ||
RUN pnpm install --frozen-lockfile --prod=false | ||
|
||
# Copy application code | ||
COPY --link . . | ||
|
||
# Build application | ||
RUN pnpm run build | ||
|
||
# Remove development dependencies | ||
RUN pnpm prune --prod | ||
|
||
|
||
# Final stage for app image | ||
FROM nginx | ||
|
||
# Copy built application | ||
# COPY --from=build /app/dist /usr/share/nginx/html | ||
|
||
# Start the server by default, this can be overwritten at runtime | ||
EXPOSE 80 | ||
CMD [ "/usr/sbin/nginx", "-g", "daemon off;" ] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
import { showRoutes } from 'hono/dev' | ||
import { createApp } from 'honox/server' | ||
|
||
const app = createApp() | ||
|
||
showRoutes(app) | ||
|
||
export default app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# fly.toml file generated for latitude-embedding-example on 2024-03-25T19:02:06+01:00 | ||
|
||
app = "latitude-embedding-example" | ||
|
||
kill_signal = "SIGINT" | ||
kill_timeout = 5 | ||
mounts = [] | ||
processes = [] | ||
|
||
[build] | ||
dockerfile = "Dockerfile" | ||
|
||
[[services]] | ||
internal_port = 8080 | ||
processes = ["app"] | ||
protocol = "tcp" | ||
|
||
[services.concurrency] | ||
hard_limit = 25 | ||
soft_limit = 20 | ||
type = "connections" | ||
|
||
[[services.ports]] | ||
force_https = true | ||
handlers = ["http"] | ||
port = 80 | ||
|
||
[[services.ports]] | ||
handlers = ["tls", "http"] | ||
port = 443 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { builtinModules } from 'module' | ||
import type { Plugin, UserConfig } from 'vite' | ||
|
||
export const nodeServerPlugin = (): Plugin => { | ||
const virtualEntryId = 'virtual:node-server-entry-module' | ||
const resolvedVirtualEntryId = '\0' + virtualEntryId | ||
|
||
return { | ||
name: '@hono/vite-node-server', | ||
resolveId(id) { | ||
if (id === virtualEntryId) { | ||
return resolvedVirtualEntryId | ||
} | ||
}, | ||
async load(id) { | ||
if (id === resolvedVirtualEntryId) { | ||
return `import { Hono } from 'hono' | ||
import { serveStatic } from '@hono/node-server/serve-static' | ||
import { serve } from '@hono/node-server' | ||
const worker = new Hono() | ||
worker.use('/static/*', serveStatic({ root: './dist' })) | ||
const modules = import.meta.glob(['/app/server.ts'], { import: 'default', eager: true }) | ||
for (const [, app] of Object.entries(modules)) { | ||
if (app) { | ||
worker.route('/', app) | ||
worker.notFound(app.notFoundHandler) | ||
} | ||
} | ||
serve({ ...worker, port: 8080 }, info => { | ||
console.log('Listening on http://localhost:'+info.port) | ||
})` | ||
} | ||
}, | ||
config: async (): Promise<UserConfig> => { | ||
return { | ||
ssr: { | ||
external: [], | ||
noExternal: true, | ||
}, | ||
build: { | ||
outDir: './dist', | ||
emptyOutDir: false, | ||
minify: true, | ||
ssr: true, | ||
rollupOptions: { | ||
external: [...builtinModules, /^node:/], | ||
input: virtualEntryId, | ||
output: { | ||
entryFileNames: 'server.mjs', | ||
}, | ||
}, | ||
}, | ||
} | ||
}, | ||
} | ||
} | ||
|
||
export default nodeServerPlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters