Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docker): use zwave-js's new pack utility, optimize layers, copy snippets #2688

Merged
merged 5 commits into from
Sep 27, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 35 additions & 23 deletions docker/Dockerfile.contrib
Original file line number Diff line number Diff line change
Expand Up @@ -41,43 +41,52 @@ ENV YARN_HTTP_TIMEOUT=300000
RUN yarn
RUN yarn build

RUN yarn plugin import version && yarn plugin import workspace-tools

# Update the version info to match the branch built
RUN yarn workspaces foreach version $(echo $(yarn node -p 'require("semver").inc(require("zwave-js/package.json").version, "prerelease")+".dev"')-$(git rev-parse --short HEAD)) --deferred && yarn version apply --all

RUN yarn workspaces foreach pack
# Pack the repo into tarballs that reference each other
RUN yarn monopack --target $(pwd) --no-version --absolute
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who has created this awesome package? 😜


### Build zwave-js-ui ###
WORKDIR /home/node/zwave-js-ui

# Change resolutions to point to local packs
# Change dependency to use local packs
RUN cat package.json \
| jq '.resolutions += { "@zwave-js/config": "file:../node-zwave-js/packages/config/package.tgz" }' \
| jq '.resolutions += { "@zwave-js/core": "file:../node-zwave-js/packages/core/package.tgz" }' \
| jq '.resolutions += { "@zwave-js/nvmedit": "file:../node-zwave-js/packages/nvmedit/package.tgz" }' \
| jq '.resolutions += { "@zwave-js/serial": "file:../node-zwave-js/packages/serial/package.tgz" }' \
| jq '.resolutions += { "@zwave-js/shared": "file:../node-zwave-js/packages/shared/package.tgz" }' \
| jq '.resolutions += { "zwave-js": "file:../node-zwave-js/packages/zwave-js/package.tgz" }' \
| jq '.dependencies += { "zwave-js": "file:../node-zwave-js/packages/zwave-js/package.tgz" }' \
> package2.json && rm package.json && mv package2.json package.json
| jq '.dependencies["zwave-js"] = "file:../node-zwave-js/zwave-js.tgz"' \
> package2.json \
&& rm package.json && mv package2.json package.json

RUN yarn
RUN yarn build

# Prune devDependencies
RUN yarn remove $(cat package.json | jq -r '.devDependencies | keys | join(" ")') && \
rm -rf \
build \
package.sh \
src \
static \
docs \
.yarn
RUN yarn remove $(cat package.json | jq -r '.devDependencies | keys | join(" ")') \
&& rm -rf \
build \
docs \
src \
static \
.yarn \
package.sh

# Copy to distribution folder
RUN mkdir my_dist
RUN cp -Lr .git package.json yarn.lock .yarnrc.yml bin config server dist hass lib store views node_modules my_dist/
RUN mkdir my_dist \
&& cp -Lr \
.git \
bin \
config \
dist \
hass \
lib \
node_modules \
server \
snippets \
store \
views \
.yarnrc.yml \
package.json \
yarn.lock \
my_dist

#####################
# Setup Final Image #
Expand All @@ -87,7 +96,10 @@ LABEL maintainer="robertsLando"

ENV ZWAVEJS_EXTERNAL_CONFIG=/usr/src/app/store/.config-db

RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
RUN \
apt-get update \
&& apt-get install -y git \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /home/node/zwave-js-ui/my_dist /usr/src/app
WORKDIR /usr/src/app
EXPOSE 8091
Expand Down