Skip to content

Commit

Permalink
Fix/docker image (ampproject#1940)
Browse files Browse the repository at this point in the history
* add docker run command

* Use tini & avoid npm start

see https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md
  • Loading branch information
sebastianbenz authored Apr 21, 2019
1 parent 4c3c1b8 commit 6544570
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ FROM node:10-alpine
WORKDIR /usr/src/app

# Install dependencies
RUN apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python
RUN apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python tini
RUN npm install --quiet node-gyp -g
# Add Tini
ENTRYPOINT ["/sbin/tini", "--"]

# Install app dependencies
COPY package.json .
Expand All @@ -16,4 +18,6 @@ RUN npm ci --only=production
COPY . .

EXPOSE 80 8080
CMD [ "npm", "start" ]
WORKDIR "platform"
ENV NODE_ENV=production
CMD ["node", "serve.js"]
10 changes: 9 additions & 1 deletion gulpfile.js/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ function imageBuild() {
return sh(`docker build --tag ${config.image.current} .`);
}

/**
* Builds a local docker image for testing.
*/
function imageRunLocal() {
return sh(`docker run -d -p 8082:80 ${config.image.current}`);
}

/**
* Builds and uploads a docker image to Google Cloud Container Registry.
*/
Expand Down Expand Up @@ -156,9 +163,10 @@ function updateStop() {
exports.verifyTag = verifyTag;
exports.gcloudSetup = gcloudSetup;
exports.deploy = series(verifyTag, imageUpload, instanceTemplateCreate, updateStart);
exports.imageBuild = imageBuild;
exports.imageList = imageList;
exports.imageRunLocal = imageRunLocal;
exports.imageUpload = imageUpload;
exports.imageBuild = imageBuild;
exports.updateStop = updateStop;
exports.updateStatus = updateStatus;
exports.updateStart = updateStart;

0 comments on commit 6544570

Please sign in to comment.