-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(build): error in alpine container image builds
Also making the build more efficient.
- Loading branch information
Showing
4 changed files
with
126 additions
and
33 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 |
---|---|---|
@@ -1,6 +1,39 @@ | ||
FROM node:12.13.1-alpine | ||
ARG NODE_VERSION=12.13.1-alpine | ||
FROM node:${NODE_VERSION} as builder | ||
|
||
RUN apk add --no-cache \ | ||
ca-certificates \ | ||
git \ | ||
gzip \ | ||
libstdc++ \ | ||
openssl \ | ||
tar | ||
|
||
WORKDIR /tmp | ||
|
||
RUN npm install [email protected] && node_modules/.bin/pkg-fetch node12 alpine x64 | ||
|
||
ADD package.json /tmp/ | ||
ADD package-lock.json /tmp/ | ||
|
||
RUN npm install \ | ||
&& rm -rf /root/.npm/* \ | ||
/usr/lib/node_modules/npm/man/* \ | ||
/usr/lib/node_modules/npm/doc/* \ | ||
/usr/lib/node_modules/npm/html/* \ | ||
/usr/lib/node_modules/npm/scripts/* | ||
|
||
ADD bin /tmp/bin | ||
ADD build /tmp/build | ||
|
||
RUN node_modules/.bin/pkg --target node12-alpine-x64 . \ | ||
&& mkdir -p /garden \ | ||
&& mv garden-service /garden/garden \ | ||
&& cp node_modules/sqlite3/lib/binding/node-v72-linux-x64/node_sqlite3.node /garden | ||
|
||
#### Main container #### | ||
FROM node:${NODE_VERSION} | ||
|
||
# system dependencies | ||
RUN apk add --no-cache \ | ||
bash \ | ||
curl \ | ||
|
@@ -13,30 +46,15 @@ RUN apk add --no-cache \ | |
gzip \ | ||
libstdc++ | ||
|
||
VOLUME ["~/.pkg-cache"] | ||
|
||
ADD bin /tmp/bin | ||
ADD build /tmp/build | ||
ADD package.json /tmp/ | ||
|
||
# build binary (need to do this in-container for alpine due to a bug in zeit/pkg) | ||
RUN cd /tmp \ | ||
&& npm install \ | ||
&& node_modules/.bin/pkg --target node12-alpine-x64 . \ | ||
&& mkdir -p /garden \ | ||
&& mv garden-service /garden/garden \ | ||
&& rm -rf node_modules \ | ||
/root/.npm/* \ | ||
/usr/lib/node_modules/npm/man/* \ | ||
/usr/lib/node_modules/npm/doc/* \ | ||
/usr/lib/node_modules/npm/html/* \ | ||
/usr/lib/node_modules/npm/scripts/* | ||
COPY --from=builder /garden /garden | ||
|
||
ADD static /garden/static | ||
RUN cd /garden/static && git init | ||
|
||
WORKDIR /project | ||
|
||
RUN ln -s /garden/garden /bin/garden \ | ||
RUN chmod +x /garden/garden \ | ||
&& ln -s /garden/garden /bin/garden \ | ||
&& chmod +x /bin/garden | ||
|
||
ENTRYPOINT ["/garden/garden"] |
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