Skip to content

Instantly share code, notes, and snippets.

@dhavaln
Created October 13, 2019 10:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dhavaln/62d83c7eac3e7a0c2c5bcc2b24d80691 to your computer and use it in GitHub Desktop.
Save dhavaln/62d83c7eac3e7a0c2c5bcc2b24d80691 to your computer and use it in GitHub Desktop.
Simple NodeJS Multistage Build
FROM node:10 as build
MAINTAINER dhavaln
LABEL description="This is a multi-stage NodeJS image"
WORKDIR /src
COPY package*.json .
RUN npm install
COPY . .
FROM node:10-slim
WORKDIR /src
COPY --from=build /src .
EXPOSE 8080
CMD ["node", "index.js"]
'use strict';
const express = require('express');
// Constants
const PORT = 8080;
const HOST = '0.0.0.0';
// App
const app = express();
app.get('/', (req, res) => {
res.send('Hello world\n');
});
app.listen(PORT, HOST);
console.log(`Running on http://${HOST}:${PORT}`);
{
"name": "multistage-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
},
"keywords": [],
"author": "dhavaln",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment