Skip to content

Commit

Permalink
support standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
inetol committed Jun 19, 2024
1 parent f4253b6 commit 29df59d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
!public/
!src/
!astro.config.ts
!build.standalone.ts
!bun.lockb
!bunfig.toml
!LICENSE
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ WORKDIR /build/
COPY . ./

RUN bun install --production --frozen-lockfile && \
bun run build:astro
bun run build:standalone

FROM docker.io/oven/bun:1-distroless
WORKDIR /frontend/

COPY --chown=nonroot --from=builder /build/dist/astro/ ./
COPY --chown=nonroot --from=builder /build/dist/prod/ ./
COPY --chown=nonroot --from=builder /build/LICENSE ./

LABEL org.opencontainers.image.url="https://jspaste.eu" \
Expand All @@ -21,4 +21,4 @@ LABEL org.opencontainers.image.url="https://jspaste.eu" \

EXPOSE 3000

CMD ["entry.mjs"]
CMD ["index.js"]
3 changes: 2 additions & 1 deletion astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default defineConfig({
client: 'dist/astro/public/'
},
server: {
host: '0.0.0.0',
port: 3000
},
vite: {
Expand All @@ -43,7 +44,7 @@ export default defineConfig({
manifest: pwaManifest,
workbox: {
globDirectory: 'dist/astro/public/',
globPatterns: ['**/*.{js,css,svg,png,jpg,jpeg,gif,webp,woff,woff2,ttf,eot,ico}'],
globPatterns: ['**/*.{js,wasm,css,html,svg,png,jpg,jpeg,gif,webp,woff,woff2,ttf,eot,ico}'],
navigateFallback: null
}
})
Expand Down
20 changes: 20 additions & 0 deletions build.standalone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { $ } from 'bun';

await Bun.build({
target: 'bun',
splitting: true,
minify: {
whitespace: true,
syntax: true,
identifiers: false
},
naming: {
entry: 'index.[ext]',
chunk: 'chunks/[hash].[ext]',
asset: 'chunks/[name].[ext]'
},
outdir: 'dist/prod/',
entrypoints: ['dist/astro/entry.mjs']
});

await $`cp -a dist/astro/public/ dist/prod/`;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"scripts": {
"build": "bun run build:astro",
"build:astro": "bun astro build",
"build:standalone": "bun run build:astro && bun run build.standalone.ts",
"fix": "bun run fix:biome && bun run fix:package",
"fix:biome": "bun biome check --write",
"fix:package": "bun sort-package-json --quiet",
Expand Down
6 changes: 3 additions & 3 deletions src/components/HeaderLabelComponent.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const { label, openWindow } = Astro.props as Props;
---

<div
class=`items-center flex gap-1 text-white ${openWindow && 'hover:bg-neutral-700 cursor-pointer'}`
style="font-size: 12px; margin: 0 5px; padding: 0 5px"
onclick={openWindow && `window.open('${openWindow}')`}
class=`items-center flex gap-1 text-white ${openWindow && 'hover:bg-neutral-700 cursor-pointer'}`
style="font-size: 12px; margin: 0 5px; padding: 0 5px"
onclick={openWindow && `window.open('${openWindow}')`}
>
<slot name="icon"/>
{label}
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/RootLayout.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { siteManifest } from '@/manifest.ts';
import { siteManifest } from '@/manifest';
import '@fontsource-variable/red-hat-text';
import '@fontsource-variable/red-hat-mono';
---
Expand Down

0 comments on commit 29df59d

Please sign in to comment.