Skip to content

Commit

Permalink
Make build and Dockerfile according to serlo's practices
Browse files Browse the repository at this point in the history
  • Loading branch information
hugotiburtino committed Oct 13, 2020
1 parent 4926e1e commit c73b8c2
Show file tree
Hide file tree
Showing 3 changed files with 6,165 additions and 127 deletions.
27 changes: 20 additions & 7 deletions cache-worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
FROM node:12
ENV CACHE_KEYS all
ENV CACHE_KEYS_RETRIES 2
WORKDIR /app
FROM node:12 as dev-dependencies
WORKDIR /usr/src/app
COPY package.json .
COPY yarn.lock .
RUN yarn --frozen-lockfile --production=false --silent

FROM node:12 as prod-dependencies
WORKDIR /usr/src/app
ENV NODE_ENV production
COPY package.json .
COPY yarn.lock .
COPY src/ ./src
RUN yarn --frozen-lockfile --production=true --silent

FROM dev-dependencies as build
COPY src src
COPY index.ts .
RUN yarn install --frozen-lockfile
CMD ["yarn", "updatecache"]
RUN yarn build

FROM prod-dependencies as release
ENV CACHE_KEYS all
ENV CACHE_KEYS_RETRIES 2
COPY --from=build /usr/src/app/dist dist
ENTRYPOINT ["node", "dist"]
6 changes: 4 additions & 2 deletions cache-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"author": "Serlo Education e.V.",
"main": "index.ts",
"scripts": {
"updatecache": "yarn ts-node index.ts"
"updatecache": "ts-node index.ts",
"build": "tsdx build --target node -i index.ts"
},
"dependencies": {
"graphql": "^15.0.0",
Expand All @@ -16,7 +17,8 @@
"typescript": "^4.0.0"
},
"devDependencies": {
"@types/node": "^14.0.0"
"@types/node": "^14.0.0",
"tsdx": "^0.14.0"
},
"engines": {
"node": "^12.0.0"
Expand Down
Loading

0 comments on commit c73b8c2

Please sign in to comment.