Skip to content

Commit

Permalink
replace standalone with export
Browse files Browse the repository at this point in the history
  • Loading branch information
inetol committed Jun 6, 2024
1 parent 3ac827e commit 0ccf821
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 61 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
!LICENSE
!next.config.js
!package.json
!serve.json
!tsconfig.json
15 changes: 7 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ WORKDIR /build/
COPY . ./

RUN bun install --production --frozen-lockfile && \
bun run build:standalone
bun install --global serve@14 && \
bun run build:static

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

COPY --chown=nonroot --from=builder /build/.next/standalone ./
COPY --chown=nonroot --from=builder /build/.next/static ./.next/static
COPY --chown=nonroot --from=builder /build/public ./public
COPY --chown=nonroot --from=builder /root/.bun/install/global/node_modules/ ./node_modules/
COPY --chown=nonroot --from=builder /build/out/ ./out/
COPY --chown=nonroot --from=builder /build/LICENSE ./
COPY --chown=nonroot --from=builder /build/serve.json ./

LABEL org.opencontainers.image.url="https://jspaste.eu" \
org.opencontainers.image.source="https://github.com/jspaste/frontend" \
Expand All @@ -20,9 +22,6 @@ LABEL org.opencontainers.image.url="https://jspaste.eu" \
org.opencontainers.image.documentation="https://docs.jspaste.eu" \
org.opencontainers.image.licenses="EUPL-1.2"

ENV HOSTNAME=0.0.0.0
ENV PORT=3000

EXPOSE 3000

CMD ["server.js"]
CMD ["node_modules/serve/build/main.js", "-L", "-u", "-n", "-l", "tcp://0.0.0.0:3000"]
Binary file modified bun.lockb
Binary file not shown.
52 changes: 6 additions & 46 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,17 @@
import million from 'million/compiler';

/** @type {import('next').NextConfig} */
const nextConfig = {
output: process.env.NEXT_OUTPUT,
const nextConfig = Object.seal({
output: undefined,
reactStrictMode: true,
poweredByHeader: false,
compiler: {
styledComponents: true,
removeConsole: true,
styledJsx: true
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '*',
port: ''
}
]
},
experimental: {
ppr: false,
optimizeCss: true,
reactCompiler: true,
webpackBuildWorker: true,
appDocumentPreloading: true,
parallelServerCompiles: true
},
async redirects() {
return [
{
source: '/github',
destination: 'https://github.com/jspaste',
permanent: true
},
{
source: '/favicon.ico',
destination: '/media/jspaste.bg.rounded.svg',
permanent: false
},
{
source: '/:key/raw',
destination: '/documents/:key/raw',
permanent: true
},
{
source: '/:key/r',
destination: '/documents/:key/raw',
permanent: true
}
];
reactCompiler: true
}
};
});

nextConfig.output = process.env.NEXT_STATIC ? 'export' : undefined;

export default million.next(nextConfig, {
rsc: true
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@
"scripts": {
"build": "bun run build:next",
"build:next": "bun next build",
"build:standalone": "NEXT_OUTPUT=standalone bun run build:next",
"build:static": "NEXT_OUTPUT=export bun run build:next",
"build:static": "NEXT_STATIC=true bun next build",
"fix": "bun run fix:biome && bun run fix:package",
"fix:biome": "bun biome check --apply .",
"fix:package": "bun sort-package-json --quiet",
"postinstall": "bun next telemetry disable",
"lint": "bun run lint:biome && bun run lint:tsc",
"lint:biome": "bun biome lint .",
"lint:tsc": "bun tsc --noEmit",
"start": "bun run build && bun next start",
"start": "bun run start:next",
"start:dev": "bun next dev",
"start:static": "bun run build:static && bun serve out/"
"start:next": "bun run build:next && bun next start",
"start:static": "bun run build:static && bun serve"
},
"browserslist": [
"last 3 version",
"> 1%",
"not dead"
],
"dependencies": {
"@chakra-ui/icons": "~2.1.1",
"@chakra-ui/next-js": "~2.2.0",
Expand Down
11 changes: 9 additions & 2 deletions public/serve.json → serve.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"rewrites": [{ "source": "/:documentId", "destination": "/document.html" }],
"public": "out/",
"rewrites": [
{
"source": "/:documentId",
"destination": "/document.html"
}
],
"redirects": [
{
"source": "/github",
Expand All @@ -21,5 +27,6 @@
"destination": "/documents/:key/raw",
"permanent": true
}
]
],
"trailingSlash": false
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"noUnusedParameters": true,
"verbatimModuleSyntax": true,

"baseUrl": ".",
"baseUrl": "./",
"paths": {
"@/*": ["./src/*"]
},
Expand Down

0 comments on commit 0ccf821

Please sign in to comment.