diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 473ccab..0d5d08c 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -5,7 +5,8 @@ management: docVersion: 0.0.3 speakeasyVersion: internal generationVersion: 2.231.0 - configChecksum: d210bf572a517293dd9174bc846ad612 + releaseVersion: 0.0.1 + configChecksum: 88bdac673170dbc3b42817fc60e8a98a published: true features: docs: @@ -2566,7 +2567,6 @@ generatedFiles: - Makefile - src/components/customRedirects.tsx - next.config.js - - server.go - Dockerfile - src/pages/_app.mdx - src/pages/python/[[...rest]].mdx diff --git a/Dockerfile b/Dockerfile index a4ccb2d..82f8284 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,31 @@ -FROM golang:1.21-alpine as builder +# Get NPM packages +FROM node:14-alpine AS dependencies +RUN apk add --no-cache libc6-compat +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci --only=production +# Rebuild the source code only when needed +FROM node:14-alpine AS builder +WORKDIR /app +COPY . . +COPY --from=dependencies /app/node_modules ./node_modules +RUN npm run build + +# Production image, copy all the files and run next +FROM node:14-alpine AS runner WORKDIR /app -RUN go mod init server +ENV NODE_ENV production -# Copy the server.go file. -COPY server.go ./ +RUN addgroup -g 1001 -S nodejs +RUN adduser -S nextjs -u 1001 -# Copy the 'out' directory -COPY out/ ./out/ +COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/package.json ./package.json -RUN go build -o /server +USER nextjs +EXPOSE 3000 -FROM gcr.io/distroless/base - -WORKDIR / - -COPY --from=builder /server /server -COPY --from=builder /app/out/ /out/ - -ENV PORT=8080 - -EXPOSE 8080 - -ENTRYPOINT ["/server"] +CMD ["npm", "start"] diff --git a/RELEASES.md b/RELEASES.md index a1661fe..f853b58 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4,4 +4,10 @@ ### Changes Based on: - OpenAPI Doc 0.0.3 -- Speakeasy CLI 1.136.1 (2.231.0) https://github.com/speakeasy-api/speakeasy \ No newline at end of file +- Speakeasy CLI 1.136.1 (2.231.0) https://github.com/speakeasy-api/speakeasy + +## 2024-01-12 14:59:14 +### Changes +Based on: +- OpenAPI Doc 0.0.3 +- Speakeasy CLI 1.136.3 (2.231.0) https://github.com/speakeasy-api/speakeasy \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 422939d..f55b1b4 100644 --- a/gen.yaml +++ b/gen.yaml @@ -7,7 +7,7 @@ generation: fixes: nameResolutionDec2023: false docs: - version: "" + version: 0.0.1 defaultLanguage: go imports: option: openapi diff --git a/next.config.js b/next.config.js index 2a27408..1b695e4 100644 --- a/next.config.js +++ b/next.config.js @@ -20,14 +20,37 @@ module.exports = withPlugins([], { sassOptions: { importer: jsonImporter(), }, - ...withNextra({ - output: 'export', - distDir: 'out', - images: { - unoptimized: true, - }, - }), + ...withNextra(), eslint: { ignoreDuringBuilds: true, }, + async redirects() { + return [ + { + source: '/', + destination: '/go/client_sdks/', + permanent: true, + }, + { + source: '/python', + destination: '/python/client_sdks/', + permanent: true, + }, + { + source: '/typescript', + destination: '/typescript/client_sdks/', + permanent: true, + }, + { + source: '/go', + destination: '/go/client_sdks/', + permanent: true, + }, + { + source: '/curl', + destination: '/curl/client_sdks/', + permanent: true, + }, + ] + }, }); diff --git a/package.json b/package.json index 9d1f464..10a99fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sdk-docs", - "version": "", + "version": "0.0.1", "description": "Nextra docs template", "private": true, "scripts": { diff --git a/server.go b/server.go deleted file mode 100644 index 3e6d005..0000000 --- a/server.go +++ /dev/null @@ -1,73 +0,0 @@ -package main - -import ( - "fmt" - "log" - "net/http" - "os" - "strings" -) - -func handler(fs http.Handler, language string) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - baseRoute := fmt.Sprintf("/%s/", language) - if !strings.HasPrefix(r.URL.Path, baseRoute) { - http.NotFound(w, r) - return - } - - r.URL.Path = baseRoute + "[[...rest]].html" - fs.ServeHTTP(w, r) - } -} - -func rootHandler(fs http.Handler) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - // There is nothing at /, so redirect to the client SDKs page for the default language - // We need to check for this explicitly because mux matches / to every route - if r.URL.Path == "/" { - http.RedirectHandler("/go/client_sdks", http.StatusSeeOther).ServeHTTP(w, r) - return - } - - // Files from public end up in the root of the build directory - if isPublicFile(r.URL.Path) { - fs.ServeHTTP(w, r) - return - } - - http.NotFound(w, r) - } -} - -func isPublicFile(path string) bool { - return strings.Count(path, "/") == 1 && strings.Count(path, ".") == 1 -} - -func main() { - fs := http.FileServer(http.Dir("./out")) - - // Serve static files generated by Next - http.Handle("/_next/", fs) - - languages := []string{"python", "typescript", "go", "curl"} - for _, language := range languages { - route := fmt.Sprintf("/%s/", language) - http.Handle(route, handler(fs, language)) - } - - // Mux will match / to every other route, so we need to handle it carefully - http.Handle("/", rootHandler(fs)) - - listeningPort := os.Getenv("PORT") - if listeningPort == "" { - // Default locally to port 3000 - listeningPort = "3000" - } - - log.Print(fmt.Sprintf("Listening on :%s...", listeningPort)) - err := http.ListenAndServe(fmt.Sprintf(":%s", listeningPort), nil) - if err != nil { - log.Fatal(err) - } -} diff --git a/src/components/customRedirects.tsx b/src/components/customRedirects.tsx index 2d791f3..fa3ad6d 100644 --- a/src/components/customRedirects.tsx +++ b/src/components/customRedirects.tsx @@ -1,6 +1,5 @@ import { useLayoutEffect } from 'react'; import { useRouter } from 'next/router'; -import { Languages, DefaultLanguage } from '@/content/languages'; type Redirect = { from: string; @@ -11,16 +10,7 @@ export const CustomRedirects = () => { const router = useRouter(); // Static redirects + custom redirects defined in theme.yaml - const redirects: Redirect[] = [ - { - from: '/', - to: `/${DefaultLanguage}/client_sdks/`, - }, - ...Languages.map((lang) => ({ - from: `/${lang}`, - to: `/${lang}/client_sdks/`, - })), - ]; + const redirects: Redirect[] = []; useLayoutEffect(() => { const currentPath = window.location.pathname;