-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: much more efficient Docker files
- Loading branch information
Showing
5 changed files
with
70 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
# API | ||
|
||
FROM node:alpine | ||
FROM node:alpine AS development | ||
|
||
RUN apk update | ||
RUN apk update \ | ||
&& apk add libexecinfo libexecinfo-dev \ | ||
&& npm i -g npm \ | ||
&& apk --no-cache add --virtual builds-deps build-base \ | ||
snappy g++ snappy-dev gcc libgcc libstdc++ linux-headers autoconf automake make nasm python git \ | ||
&& npm install --quiet node-gyp -g \ | ||
&& npm config set python /usr/bin/python \ | ||
&& npm install yarn -g | ||
|
||
RUN npm i -g npm | ||
RUN mkdir /srv/gauzy && chown node:node /srv/gauzy | ||
|
||
RUN apk add libexecinfo libexecinfo-dev | ||
USER node | ||
|
||
RUN apk --no-cache add --virtual builds-deps build-base \ | ||
snappy g++ snappy-dev gcc libgcc libstdc++ linux-headers autoconf automake make nasm python git && \ | ||
npm install --quiet node-gyp -g | ||
WORKDIR /srv/gauzy | ||
|
||
RUN npm config set python /usr/bin/python | ||
COPY --chown=node:node package.json yarn.lock ./ | ||
COPY --chown=node:node apps/api/package.json ./apps/api/package.json | ||
# COPY .snyk /tmp/.snyk | ||
RUN yarn install | ||
|
||
RUN npm install yarn -g | ||
FROM node:alpine AS production | ||
|
||
RUN npm install cross-env -g | ||
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.6.0/wait /wait | ||
|
||
RUN npm install pm2 -g --unsafe-perm | ||
RUN npm install cross-env -g \ | ||
&& npm install pm2 -g --unsafe-perm \ | ||
&& chmod +x /wait | ||
|
||
# Make our app folder (empty for now) | ||
RUN mkdir -p /usr/src/app | ||
USER node | ||
|
||
# Provides cached layer for node_modules and bower_components | ||
COPY package.json /tmp/package.json | ||
COPY apps/api/package.json /tmp/apps/api/package.json | ||
# COPY .snyk /tmp/.snyk | ||
COPY yarn.lock /tmp/yarn.lock | ||
RUN cd /tmp/ && yarn install | ||
RUN cp -a /tmp/node_modules /usr/src/app/ | ||
RUN cd /usr/src/app | ||
WORKDIR /srv/gauzy | ||
|
||
WORKDIR /usr/src/app | ||
ARG NODE_OPTIONS="--max-old-space-size=2048" | ||
ENV NODE_OPTIONS $NODE_OPTIONS | ||
ENV NODE_ENV production | ||
|
||
# Bundle app source | ||
ADD . /usr/src/app | ||
COPY --from=development --chown=root:root /srv/gauzy/node_modules ./node_modules | ||
COPY --from=development --chown=root:root /srv/gauzy/apps/api/node_modules ./apps/api/node_modules | ||
|
||
EXPOSE 3000 | ||
COPY . . | ||
|
||
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.6.0/wait /wait | ||
RUN chmod +x /wait | ||
EXPOSE 3000 | ||
|
||
CMD /wait && cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=2048 yarn ng serve api --host 0.0.0.0 -c=production --prod |
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,47 +1,47 @@ | ||
# Webapp | ||
|
||
FROM node:alpine | ||
FROM node:alpine AS development | ||
|
||
RUN apk update | ||
RUN apk update \ | ||
&& apk add libexecinfo libexecinfo-dev \ | ||
&& npm i -g npm \ | ||
&& apk --no-cache add --virtual builds-deps build-base \ | ||
snappy g++ snappy-dev gcc libgcc libstdc++ linux-headers autoconf automake make nasm python git \ | ||
&& npm install --quiet node-gyp -g \ | ||
&& npm config set python /usr/bin/python \ | ||
&& npm install yarn -g | ||
|
||
RUN npm i -g npm | ||
RUN mkdir /srv/gauzy && chown node:node /srv/gauzy | ||
|
||
RUN apk add libexecinfo libexecinfo-dev | ||
USER node | ||
|
||
RUN apk --no-cache add --virtual builds-deps build-base \ | ||
snappy g++ snappy-dev gcc libgcc libstdc++ linux-headers autoconf automake make nasm python git && \ | ||
npm install --quiet node-gyp -g | ||
WORKDIR /srv/gauzy | ||
|
||
RUN npm config set python /usr/bin/python | ||
COPY --chown=node:node package.json yarn.lock ./ | ||
COPY --chown=node:node apps/api/package.json ./apps/api/package.json | ||
# COPY .snyk /tmp/.snyk | ||
RUN yarn install | ||
|
||
RUN npm install yarn -g | ||
FROM node:alpine AS production | ||
|
||
RUN npm install cross-env -g | ||
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.6.0/wait /wait | ||
|
||
RUN npm install pm2 -g --unsafe-perm | ||
RUN npm install cross-env -g \ | ||
&& npm install pm2 -g --unsafe-perm \ | ||
&& chmod +x /wait | ||
|
||
# Make our app folder (empty for now) | ||
RUN mkdir -p /usr/src/app | ||
USER node | ||
|
||
# Provides cached layer for node_modules and bower_components | ||
COPY package.json /tmp/package.json | ||
# COPY .snyk /tmp/.snyk | ||
COPY yarn.lock /tmp/yarn.lock | ||
RUN cd /tmp/ && yarn install | ||
RUN cp -a /tmp/node_modules /usr/src/app/ | ||
RUN cd /usr/src/app | ||
WORKDIR /srv/gauzy | ||
|
||
WORKDIR /usr/src/app | ||
ARG NODE_OPTIONS="--max-old-space-size=2048" | ||
ENV NODE_OPTIONS $NODE_OPTIONS | ||
ENV NODE_ENV production | ||
|
||
# Bundle app source | ||
ADD . /usr/src/app | ||
COPY --from=development --chown=root:root /srv/gauzy/node_modules ./node_modules | ||
|
||
EXPOSE 4200 | ||
COPY . . | ||
|
||
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.6.0/wait /wait | ||
RUN chmod +x /wait | ||
EXPOSE 4200 | ||
|
||
CMD /wait && cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=2048 yarn run config:prod && yarn ng serve gauzy --disable-host-check --host 0.0.0.0 -c=production --prod |
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