-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: make docker great again (#1709)
* wip docker * fix docker build issues * add ComposerDialogs folder to bot runtime image * don't log error when git is missing * make app data.json path configurable allows us to save docker state across builds * add compose override example * no need to be in composer directory * finish comment and remove dead code * use correct syntax for run directive
- Loading branch information
1 parent
9d93ad8
commit 01cd533
Showing
14 changed files
with
95 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -397,3 +397,7 @@ MyBots/* | |
|
||
# VsCode | ||
Composer/.vscode/ | ||
|
||
# Docker App Data | ||
.appdata | ||
docker-compose.override.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,34 @@ | ||
FROM node:12-alpine as build | ||
WORKDIR /src/Composer | ||
|
||
# yes, docker copy is really this stupid, https://github.com/moby/moby/issues/15858 | ||
COPY yarn.lock . | ||
COPY .npmrc . | ||
COPY package.json . | ||
COPY packages/client/package.json ./packages/client/ | ||
COPY yarn.lock ./packages/server/ | ||
COPY packages/server/package.json ./packages/server/ | ||
COPY packages/lib/package.json ./packages/lib/ | ||
COPY packages/lib/code-editor/package.json ./packages/lib/code-editor/ | ||
COPY packages/lib/shared/package.json ./packages/lib/shared/ | ||
COPY packages/lib/indexers/package.json ./packages/lib/indexers/ | ||
COPY packages/extensions/package.json ./packages/extensions/ | ||
COPY packages/lib/eslint-plugin-bfcomposer/package.json ./packages/lib/eslint-plugin-bfcomposer/ | ||
COPY packages/extensions/obiformeditor/package.json ./packages/extensions/obiformeditor/ | ||
COPY packages/extensions/visual-designer/package.json ./packages/extensions/visual-designer/ | ||
################# | ||
# | ||
# Because Composer is organized as a monorepo with multiple packages | ||
# managed by yarn workspaces, our Dockerfile may not look like other | ||
# node / react projects. Specifically, we have to add all source files | ||
# before doing yarn install due to yarn workspace symlinking. | ||
# | ||
################ | ||
|
||
# run yarn install as a distinct layer | ||
RUN yarn install | ||
FROM node:12-alpine as build | ||
|
||
WORKDIR /src/Composer | ||
COPY . . | ||
# run yarn install as a distinct layer | ||
RUN yarn install --frozen-lock-file | ||
ENV NODE_OPTIONS "--max-old-space-size=4096" | ||
ENV NODE_ENV "production" | ||
RUN yarn build:prod | ||
|
||
|
||
# use a multi-stage build to reduce the final image size | ||
FROM node:12-alpine | ||
|
||
WORKDIR /app/Composer/server | ||
COPY --from=build /src/Composer/.npmrc . | ||
COPY --from=build /src/Composer/packages/lib ./lib | ||
COPY --from=build /src/Composer/packages/server . | ||
|
||
# update server package json to point to local packages | ||
RUN node ./prepare-prod.js | ||
WORKDIR /app/Composer | ||
COPY --from=build /src/Composer/yarn.lock . | ||
COPY --from=build /src/Composer/package.json . | ||
COPY --from=build /src/Composer/packages/server ./packages/server | ||
COPY --from=build /src/Composer/packages/lib ./packages/lib | ||
COPY --from=build /src/Composer/packages/tools ./packages/tools | ||
|
||
RUN yarn --production && yarn cache clean | ||
CMD ["node", "build/server.js"] | ||
ENV NODE_ENV "production" | ||
RUN yarn --production --frozen-lockfile --force && yarn cache clean | ||
WORKDIR /app/Composer | ||
CMD ["yarn", "start:server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Use this to override Composer's default docker configuration | ||
|
||
version: "3" | ||
services: | ||
composer: | ||
volumes: | ||
- /Some/path/to/my/bots:/Bots | ||
environment: | ||
DEBUG: composer | ||
botruntime: | ||
volumes: | ||
- /Some/path/to/my/bots:/Bots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters