Skip to content

Commit 64b7bce

Browse files
Fix build and prepare step (#3)
yarn install will install devdependencies - additionally it runs yarn prepublish (because that's how it works) - this in turn runs yarn test - this in turn runs yarn build (what we want) and jest (to validate) This means that the tests MUST be present when building the image. They are *not* copied over, so this is not an issues. Additionally, this creates a new production_node_modules folder with the right flags set, so that the final image node_modules is extremely small.
1 parent 9d2ce8f commit 64b7bce

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
test
21
dist
32
node_modules
43
.git

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
node_modules
2+
production_node_modules
23
dist
34
yarn-error.log
45
analysis.json
6+
tmp

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
3+
## 0.1.1
4+
5+
Fixes the build and prepare step of the Docker-based image
6+
7+
## 0.1.0
8+
9+
:baby: initial release

Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@ RUN apk update && apk add ca-certificates
77
RUN adduser -D -g '' appuser
88

99
# get the source code
10-
WORKDIR /typescript-analyzer
10+
WORKDIR /javascript-analyzer
1111
COPY . .
1212

13-
# build
14-
RUN yarn install && yarn build && yarn install --prod
13+
# Install without arguments runs yarn prepublish
14+
RUN yarn install
15+
16+
# Only install the node_modules we need
17+
RUN yarn install --production --modules-folder './production_node_modules'
1518

1619
# Build a minimal and secured container
1720
FROM node:lts-alpine
1821
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
1922
COPY --from=builder /etc/passwd /etc/passwd
20-
COPY --from=builder /typescript-analyzer/bin /opt/analyzer/bin
21-
COPY --from=builder /typescript-analyzer/dist /opt/analyzer/dist
22-
COPY --from=builder /typescript-analyzer/node_modules /opt/analyzer/node_modules
23+
COPY --from=builder /javascript-analyzer/bin /opt/analyzer/bin
24+
COPY --from=builder /javascript-analyzer/dist /opt/analyzer/dist
25+
COPY --from=builder /javascript-analyzer/production_node_modules /opt/analyzer/node_modules
2326
USER appuser
2427
WORKDIR /opt/analyzer
2528
ENTRYPOINT ["/opt/analyzer/bin/analyze.sh"]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@exercism/typescript-analyzer",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Exercism analyzer for typescript",
55
"main": "dist/analyze.js",
66
"repository": "https://github.com/exercism/typescript-analyzer",

0 commit comments

Comments
 (0)