Skip to content

Commit 6c6f3ed

Browse files
committed
feat: copy dockerfile from http utils if selected
1 parent d2557d2 commit 6c6f3ed

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/lib/answerHandlers/createNewProjectFiles.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class CreateNewProjectFiles {
5858
fs.mkdirSync(this.path);
5959
}
6060
//only add if Dockerfile option was selected
61-
if (this.answers['project-dockerfile-enabled']) {
61+
if (this.answers['project-dockerfile-enabled'] && this.answers["project-type"] !== "http-api@express-utils") {
6262
this.addDocker();
6363
}
6464
//eslint / prettier
@@ -202,6 +202,11 @@ export class CreateNewProjectFiles {
202202
path.join(this.path, 'test'),
203203
{ recursive: true }
204204
);
205+
fs.cpSync(
206+
path.join(this.staticPath, 'example_src', 'express-utils-template', 'Dockerfile'),
207+
path.join(this.path, 'Dockerfile'),
208+
{ recursive: true }
209+
);
205210
break;
206211
case 'empty-project':
207212
fs.cpSync(path.join(this.staticPath, 'example_src', 'empty_project'), path.join(this.path, 'src'), {

static/Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
FROM node:16-alpine3.16 AS builder
1+
FROM node:18-alpine3.18 AS builder
22

33
WORKDIR /build
44

55
# install dependencies
66
# copy only package.json files for better caching
77
# (if no dependencies are changed, there is no need to reinstall them, so it is faster to use the cache)
88
COPY package*.json ./
9-
RUN npm ci
9+
RUN npm ci --fund=false
1010
# copy rest of src files etc.
1111
COPY . .
1212

1313
# build and install only production dependencies
1414
RUN npm run build
1515
# install only production dependencies for reducing image size and security (no need for dev dependencies in prod env)
16-
RUN npm ci --only=production
16+
RUN npm ci --omit=dev --audit=false --fund=false
1717

1818

1919
######################################################################
2020

21-
FROM node:16-alpine3.16
21+
FROM node:18-alpine3.18
2222

2323
WORKDIR /app
2424

25-
MAINTAINER Nico W. <[email protected]>
25+
LABEL org.opencontainers.image.authors="Nico W. <[email protected]>"
2626

2727
EXPOSE 8080
2828

29-
# [IF WANTED] enable docker healthcheck for @kopf02/express-utils package
30-
#HEALTHCHECK --interval=10s --retries=2 CMD npx docker-healthcheck || exit 1
29+
HEALTHCHECK --interval=10s --retries=2 CMD npx docker-healthcheck || exit 1
3130

3231
# copy files from build stage
3332
COPY --from=builder /build/dist/ dist/

0 commit comments

Comments
 (0)