better-ts-stack 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -113
- package/dist/args.js +24 -20
- package/dist/builder/buildPlanner.js +1 -1
- package/dist/builder/configGenerator.js +1 -5
- package/dist/builder/index.js +15 -3
- package/dist/builder/moduleSelector.js +4 -2
- package/dist/builder/readmeGenerator.js +101 -0
- package/dist/builder/templateContext.js +30 -0
- package/dist/index.js +7 -1
- package/dist/output/nextSteps.js +19 -22
- package/dist/prompts/index.js +2 -1
- package/dist/prompts/stack.js +21 -2
- package/dist/types/index.js +1 -0
- package/dist/ui/messages.js +2 -1
- package/dist/validators/index.js +5 -2
- package/package.json +1 -1
- package/templates/backend/express/config.json +42 -40
- package/templates/backend/express/src/env.ts.hbs +39 -0
- package/templates/backend/express/src/index.ts.hbs +111 -75
- package/templates/backend/nestjs/config.json +43 -41
- package/templates/backend/nestjs/src/app.module.ts.hbs +13 -0
- package/templates/backend/nestjs/src/env.ts.hbs +39 -0
- package/templates/backend/nestjs/src/main.ts +3 -2
- package/templates/frontend/nextjs/app/page.tsx.hbs +98 -97
- package/templates/frontend/tanstack/config.json +2 -2
- package/templates/frontend/tanstack/src/routes/index.tsx.hbs +102 -101
- package/templates/frontend/tanstack/vite.config.ts +22 -14
- package/templates/modules/auth/express/config.json +20 -20
- package/templates/modules/auth/express/src/routes/auth.ts.hbs +27 -19
- package/templates/modules/auth/nestjs/config.json +20 -20
- package/templates/modules/auth/nestjs/src/auth/{auth.controller.ts → auth.controller.ts.hbs} +15 -0
- package/templates/modules/auth/tanstack/src/components/auth/sign-in-form.tsx +132 -134
- package/templates/modules/auth/tanstack/src/components/auth/sign-out-button.tsx +46 -48
- package/templates/modules/auth/tanstack/src/components/auth/sign-up-form.tsx +150 -152
- package/templates/modules/docker/.dockerignore +1 -0
- package/templates/modules/docker/Dockerfile.hbs +147 -136
- package/templates/modules/docker/docker-compose.yml.hbs +96 -1
- package/templates/modules/rate-limit/express/config.json +12 -0
- package/templates/modules/rate-limit/express/src/middleware/rateLimit.ts +21 -0
- package/templates/modules/rate-limit/nestjs/config.json +12 -0
|
@@ -1,153 +1,151 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
>
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
</Card>
|
|
152
|
-
);
|
|
1
|
+
import { Link, useNavigate } from "@tanstack/react-router";
|
|
2
|
+
import { useState, useTransition } from "react";
|
|
3
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
|
+
import { LoaderCircle } from "lucide-react";
|
|
5
|
+
import { useForm } from "react-hook-form";
|
|
6
|
+
|
|
7
|
+
import { authClient } from "~/lib/auth-client";
|
|
8
|
+
import {
|
|
9
|
+
getAuthErrorMessage,
|
|
10
|
+
signUpSchema,
|
|
11
|
+
type SignUpValues,
|
|
12
|
+
} from "~/lib/auth-schema";
|
|
13
|
+
import { Button } from "~/components/ui/button";
|
|
14
|
+
import {
|
|
15
|
+
Card,
|
|
16
|
+
CardContent,
|
|
17
|
+
CardDescription,
|
|
18
|
+
CardFooter,
|
|
19
|
+
CardHeader,
|
|
20
|
+
CardTitle,
|
|
21
|
+
} from "~/components/ui/card";
|
|
22
|
+
import {
|
|
23
|
+
Field,
|
|
24
|
+
FieldDescription,
|
|
25
|
+
FieldError,
|
|
26
|
+
FieldGroup,
|
|
27
|
+
FieldLabel,
|
|
28
|
+
} from "~/components/ui/field";
|
|
29
|
+
import { Input } from "~/components/ui/input";
|
|
30
|
+
|
|
31
|
+
export function SignUpForm() {
|
|
32
|
+
const navigate = useNavigate();
|
|
33
|
+
const [isPending, startTransition] = useTransition();
|
|
34
|
+
const [authError, setAuthError] = useState<string | null>(null);
|
|
35
|
+
const form = useForm<SignUpValues>({
|
|
36
|
+
resolver: zodResolver(signUpSchema),
|
|
37
|
+
defaultValues: {
|
|
38
|
+
name: "",
|
|
39
|
+
email: "",
|
|
40
|
+
password: "",
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const onSubmit = form.handleSubmit((values) => {
|
|
45
|
+
setAuthError(null);
|
|
46
|
+
|
|
47
|
+
startTransition(async () => {
|
|
48
|
+
const result = await authClient.signUp.email({
|
|
49
|
+
name: values.name,
|
|
50
|
+
email: values.email,
|
|
51
|
+
password: values.password,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (result.error) {
|
|
55
|
+
setAuthError(getAuthErrorMessage(result.error));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
navigate({ to: "/dashboard" });
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<Card className="border-white/80 bg-white/90 shadow-2xl shadow-slate-200/70 backdrop-blur">
|
|
65
|
+
<CardHeader className="space-y-2">
|
|
66
|
+
<CardTitle>Create your account</CardTitle>
|
|
67
|
+
<CardDescription>
|
|
68
|
+
Start with a simple email and password sign-up flow powered by Better
|
|
69
|
+
Auth.
|
|
70
|
+
</CardDescription>
|
|
71
|
+
</CardHeader>
|
|
72
|
+
<CardContent>
|
|
73
|
+
<form className="space-y-6" onSubmit={onSubmit} noValidate>
|
|
74
|
+
<FieldGroup>
|
|
75
|
+
<Field data-invalid={Boolean(form.formState.errors.name)}>
|
|
76
|
+
<FieldLabel htmlFor="name">Full name</FieldLabel>
|
|
77
|
+
<Input
|
|
78
|
+
id="name"
|
|
79
|
+
autoComplete="name"
|
|
80
|
+
aria-invalid={Boolean(form.formState.errors.name)}
|
|
81
|
+
placeholder="Ada Lovelace"
|
|
82
|
+
{...form.register("name")}
|
|
83
|
+
/>
|
|
84
|
+
<FieldError errors={[form.formState.errors.name]} />
|
|
85
|
+
</Field>
|
|
86
|
+
|
|
87
|
+
<Field data-invalid={Boolean(form.formState.errors.email)}>
|
|
88
|
+
<FieldLabel htmlFor="email">Email</FieldLabel>
|
|
89
|
+
<Input
|
|
90
|
+
id="email"
|
|
91
|
+
type="email"
|
|
92
|
+
autoComplete="email"
|
|
93
|
+
aria-invalid={Boolean(form.formState.errors.email)}
|
|
94
|
+
placeholder="you@example.com"
|
|
95
|
+
{...form.register("email")}
|
|
96
|
+
/>
|
|
97
|
+
<FieldDescription>
|
|
98
|
+
This email will be used for future sign-ins.
|
|
99
|
+
</FieldDescription>
|
|
100
|
+
<FieldError errors={[form.formState.errors.email]} />
|
|
101
|
+
</Field>
|
|
102
|
+
|
|
103
|
+
<Field data-invalid={Boolean(form.formState.errors.password)}>
|
|
104
|
+
<FieldLabel htmlFor="password">Password</FieldLabel>
|
|
105
|
+
<Input
|
|
106
|
+
id="password"
|
|
107
|
+
type="password"
|
|
108
|
+
autoComplete="new-password"
|
|
109
|
+
aria-invalid={Boolean(form.formState.errors.password)}
|
|
110
|
+
placeholder="Create a strong password"
|
|
111
|
+
{...form.register("password")}
|
|
112
|
+
/>
|
|
113
|
+
<FieldDescription>
|
|
114
|
+
Use at least 8 characters for the generated starter flow.
|
|
115
|
+
</FieldDescription>
|
|
116
|
+
<FieldError errors={[form.formState.errors.password]} />
|
|
117
|
+
</Field>
|
|
118
|
+
</FieldGroup>
|
|
119
|
+
|
|
120
|
+
{authError ? (
|
|
121
|
+
<div className="rounded-2xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700">
|
|
122
|
+
{authError}
|
|
123
|
+
</div>
|
|
124
|
+
) : null}
|
|
125
|
+
|
|
126
|
+
<Button className="w-full" type="submit" disabled={isPending}>
|
|
127
|
+
{isPending ? (
|
|
128
|
+
<>
|
|
129
|
+
<LoaderCircle className="mr-2 size-4 animate-spin" />
|
|
130
|
+
Creating account
|
|
131
|
+
</>
|
|
132
|
+
) : (
|
|
133
|
+
"Signup"
|
|
134
|
+
)}
|
|
135
|
+
</Button>
|
|
136
|
+
</form>
|
|
137
|
+
</CardContent>
|
|
138
|
+
<CardFooter className="justify-center">
|
|
139
|
+
<p className="text-sm text-slate-600">
|
|
140
|
+
Already have an account?{" "}
|
|
141
|
+
<Link
|
|
142
|
+
className="font-medium text-sky-700 hover:text-sky-800"
|
|
143
|
+
to="/sign-in"
|
|
144
|
+
>
|
|
145
|
+
Login
|
|
146
|
+
</Link>
|
|
147
|
+
</p>
|
|
148
|
+
</CardFooter>
|
|
149
|
+
</Card>
|
|
150
|
+
);
|
|
153
151
|
}
|
|
@@ -1,136 +1,147 @@
|
|
|
1
|
-
{{#if (eq framework 'nextjs')}}
|
|
2
|
-
# Base stage
|
|
3
|
-
FROM node:24-alpine AS base
|
|
4
|
-
WORKDIR /app
|
|
5
|
-
RUN apk add --no-cache libc6-compat
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{{
|
|
23
|
-
|
|
24
|
-
{{
|
|
25
|
-
|
|
26
|
-
{{/if}}
|
|
27
|
-
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{{#if
|
|
57
|
-
|
|
58
|
-
{{
|
|
59
|
-
|
|
60
|
-
{{
|
|
61
|
-
RUN
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
RUN
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
#
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
COPY --from=builder --chown=tanstackuser:nodejs /app
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
CMD
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
{{
|
|
103
|
-
RUN
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
#
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
{{
|
|
1
|
+
{{#if (eq framework 'nextjs')}}
|
|
2
|
+
# Base stage
|
|
3
|
+
FROM node:24-alpine AS base
|
|
4
|
+
WORKDIR /app
|
|
5
|
+
RUN apk add --no-cache libc6-compat
|
|
6
|
+
{{#if docker.setup}}
|
|
7
|
+
{{docker.setup}}
|
|
8
|
+
{{/if}}
|
|
9
|
+
|
|
10
|
+
# Dependencies stage
|
|
11
|
+
FROM base AS deps
|
|
12
|
+
COPY {{docker.manifests}} ./
|
|
13
|
+
RUN {{docker.install}}
|
|
14
|
+
|
|
15
|
+
# Build stage
|
|
16
|
+
FROM base AS builder
|
|
17
|
+
COPY --from=deps /app/node_modules ./node_modules
|
|
18
|
+
COPY . .
|
|
19
|
+
{{#if useAuth}}
|
|
20
|
+
# next build loads the auth route, which initializes Better Auth. The build gets
|
|
21
|
+
# a placeholder secret for this command only; the real one is supplied at runtime.
|
|
22
|
+
{{/if}}
|
|
23
|
+
{{#if (eq database 'prisma')}}
|
|
24
|
+
RUN {{#if useAuth}}BETTER_AUTH_SECRET="build-only-placeholder-secret-not-used-at-runtime" {{/if}}DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres" {{docker.run}} build
|
|
25
|
+
{{else if (eq database 'mongoose')}}
|
|
26
|
+
RUN {{#if useAuth}}BETTER_AUTH_SECRET="build-only-placeholder-secret-not-used-at-runtime" {{/if}}MONGODB_URI="mongodb://localhost:27017/build" {{docker.run}} build
|
|
27
|
+
{{else}}
|
|
28
|
+
RUN {{#if useAuth}}BETTER_AUTH_SECRET="build-only-placeholder-secret-not-used-at-runtime" {{/if}}{{docker.run}} build
|
|
29
|
+
{{/if}}
|
|
30
|
+
|
|
31
|
+
# Production stage
|
|
32
|
+
FROM node:24-alpine AS runner
|
|
33
|
+
WORKDIR /app
|
|
34
|
+
ENV NODE_ENV=production
|
|
35
|
+
|
|
36
|
+
RUN addgroup --system --gid 1001 nodejs && \
|
|
37
|
+
adduser --system --uid 1001 nextjs
|
|
38
|
+
|
|
39
|
+
COPY --from=builder /app/public ./public
|
|
40
|
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
41
|
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
42
|
+
|
|
43
|
+
USER nextjs
|
|
44
|
+
EXPOSE {{port}}
|
|
45
|
+
ENV PORT={{port}} HOSTNAME=0.0.0.0
|
|
46
|
+
|
|
47
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
|
48
|
+
CMD wget -q -O /dev/null http://127.0.0.1:{{port}}/ || exit 1
|
|
49
|
+
|
|
50
|
+
CMD ["node", "server.js"]
|
|
51
|
+
|
|
52
|
+
{{else if (eq framework 'tanstack')}}
|
|
53
|
+
# Build stage
|
|
54
|
+
FROM node:24-alpine AS builder
|
|
55
|
+
WORKDIR /app
|
|
56
|
+
{{#if docker.setup}}
|
|
57
|
+
{{docker.setup}}
|
|
58
|
+
{{/if}}
|
|
59
|
+
|
|
60
|
+
COPY {{docker.manifests}} ./
|
|
61
|
+
RUN {{docker.install}}
|
|
62
|
+
|
|
63
|
+
COPY . .
|
|
64
|
+
|
|
65
|
+
{{#if (eq database 'prisma')}}
|
|
66
|
+
RUN DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres" {{docker.run}} build
|
|
67
|
+
{{else if (eq database 'mongoose')}}
|
|
68
|
+
RUN MONGODB_URI="mongodb://localhost:27017/build" {{docker.run}} build
|
|
69
|
+
{{else}}
|
|
70
|
+
RUN {{docker.run}} build
|
|
71
|
+
{{/if}}
|
|
72
|
+
|
|
73
|
+
# Production stage. Nitro bundles the server and the dependencies it needs
|
|
74
|
+
# into .output, so no install is needed here
|
|
75
|
+
FROM node:24-alpine
|
|
76
|
+
WORKDIR /app
|
|
77
|
+
ENV NODE_ENV=production
|
|
78
|
+
|
|
79
|
+
# Create non-root user for security
|
|
80
|
+
RUN addgroup --system --gid 1001 nodejs && \
|
|
81
|
+
adduser --system --uid 1001 tanstackuser
|
|
82
|
+
|
|
83
|
+
COPY --from=builder --chown=tanstackuser:nodejs /app/.output ./.output
|
|
84
|
+
|
|
85
|
+
USER tanstackuser
|
|
86
|
+
EXPOSE {{port}}
|
|
87
|
+
ENV PORT={{port}}
|
|
88
|
+
|
|
89
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
|
90
|
+
CMD wget -q -O /dev/null http://127.0.0.1:{{port}}/ || exit 1
|
|
91
|
+
|
|
92
|
+
CMD ["node", ".output/server/index.mjs"]
|
|
93
|
+
|
|
94
|
+
{{else}}
|
|
95
|
+
# Build stage
|
|
96
|
+
FROM node:24-alpine AS builder
|
|
97
|
+
WORKDIR /app
|
|
98
|
+
{{#if docker.setup}}
|
|
99
|
+
{{docker.setup}}
|
|
100
|
+
{{/if}}
|
|
101
|
+
|
|
102
|
+
COPY {{docker.manifests}} ./
|
|
103
|
+
RUN {{docker.install}}
|
|
104
|
+
|
|
105
|
+
COPY . .
|
|
106
|
+
|
|
107
|
+
{{#if (eq database 'prisma')}}
|
|
108
|
+
RUN DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres" {{docker.run}} build
|
|
109
|
+
{{else if (eq database 'mongoose')}}
|
|
110
|
+
RUN MONGODB_URI="mongodb://localhost:27017/build" {{docker.run}} build
|
|
111
|
+
{{else}}
|
|
112
|
+
RUN {{docker.run}} build
|
|
113
|
+
{{/if}}
|
|
114
|
+
|
|
115
|
+
# Production stage
|
|
116
|
+
FROM node:24-alpine
|
|
117
|
+
WORKDIR /app
|
|
118
|
+
ENV NODE_ENV=production
|
|
119
|
+
{{#if docker.setup}}
|
|
120
|
+
{{docker.setup}}
|
|
121
|
+
{{/if}}
|
|
122
|
+
|
|
123
|
+
# Create non-root user for security
|
|
124
|
+
RUN addgroup --system --gid 1001 nodejs && \
|
|
125
|
+
adduser --system --uid 1001 appuser
|
|
126
|
+
|
|
127
|
+
COPY {{docker.manifests}} ./
|
|
128
|
+
# Clear the download cache in the same layer so it does not ship in the image
|
|
129
|
+
RUN {{docker.installProduction}} \
|
|
130
|
+
&& {{docker.cleanCache}}
|
|
131
|
+
|
|
132
|
+
# Copy the compiled output
|
|
133
|
+
COPY --from=builder --chown=appuser:nodejs /app/dist ./dist
|
|
134
|
+
|
|
135
|
+
USER appuser
|
|
136
|
+
EXPOSE {{port}}
|
|
137
|
+
ENV PORT={{port}}
|
|
138
|
+
|
|
139
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
|
140
|
+
CMD wget -q -O /dev/null http://127.0.0.1:{{port}}/health || exit 1
|
|
141
|
+
|
|
142
|
+
{{#if (eq framework 'nestjs')}}
|
|
143
|
+
CMD ["node", "dist/main.js"]
|
|
144
|
+
{{else}}
|
|
145
|
+
CMD ["node", "dist/index.js"]
|
|
146
|
+
{{/if}}
|
|
147
|
+
{{/if}}
|