Skip to content

Commit

Permalink
chore: update Dockerfile and add entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Apr 23, 2021
1 parent fd1fba8 commit 0fa60d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
36 changes: 14 additions & 22 deletions Dockerfile
@@ -1,17 +1,19 @@
# BUILD STAGE
FROM debian:stretch as build-stage

ENV BUILD_DIR /root/build/cncjs
ENV BUILD_DIR /tmp/build
ENV NVM_DIR /root/.nvm
ENV NODE_VERSION v12.22.1
ENV NODE_ENV production
ENV NODE_PATH $NVM_DIR/$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH

RUN apt-get update -y && apt-get install -y -q --no-install-recommends \
apt-utils \
ca-certificates \
python-pip \
git \
curl \
git \
make \
g++ \
udev
Expand All @@ -24,39 +26,29 @@ RUN git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" \
&& nvm alias default "$NODE_VERSION" \
&& nvm use --delete-prefix default

WORKDIR $BUILD_DIR
COPY ./dist/cncjs $BUILD_DIR
COPY ./dist/cncjs $BUILD_DIR/cncjs
COPY ./entrypoint $BUILD_DIR/entrypoint

WORKDIR $BUILD_DIR/cncjs
RUN npm install -g npm@latest && npm install -g yarn && yarn --production

# FINAL STAGE
FROM debian:stretch

ENV BUILD_DIR /root/build
ENV NVM_DIR /root/.nvm
ENV NODE_VERSION v12.22.1
ENV NODE_ENV production
ENV NODE_PATH $NVM_DIR/$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH

RUN apt-get update -y && apt-get install -y -q --no-install-recommends \
python-pip \
git \
curl \
make \
g++ \
ca-certificates \
udev

RUN git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" \
&& cd "$NVM_DIR" \
&& git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)` \
&& . "$NVM_DIR/nvm.sh" \
&& nvm install "$NODE_VERSION" \
&& nvm alias default "$NODE_VERSION" \
&& nvm use --delete-prefix default

WORKDIR /home/cncjs
COPY --from=build-stage $BUILD_DIR /home/cncjs

WORKDIR /opt/cncjs
EXPOSE 8000
CMD [ "node", "-p", "require('./server-cli')()" ]
ENTRYPOINT ["/entrypoint"]

COPY --from=build-stage /root/.nvm $NVM_DIR
COPY --from=build-stage /tmp/build/cncjs /opt/cncjs
COPY --from=build-stage /tmp/build/entrypoint /entrypoint
7 changes: 7 additions & 0 deletions entrypoint
@@ -0,0 +1,7 @@
#!/usr/bin/env node

const launchServer = require('/opt/cncjs/server-cli').default;

launchServer().catch(err => {
console.error('Error:', err);
});

0 comments on commit 0fa60d6

Please sign in to comment.