Created
October 13, 2019 10:45
-
-
Save dhavaln/62d83c7eac3e7a0c2c5bcc2b24d80691 to your computer and use it in GitHub Desktop.
Simple NodeJS Multistage Build
This file contains hidden or 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
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"] |
This file contains hidden or 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
'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}`); |
This file contains hidden or 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
{ | |
"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