Created
December 19, 2020 09:16
-
-
Save mimiz/69502dcd69318e1f9d9cfa823610462e to your computer and use it in GitHub Desktop.
node-simple-exemple-inject-vars-with-docker
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
FROM node:12-alpine | |
ENV MYAPP_DB_URL=CHANGE_ME | |
EXPOSE 3000 | |
WORKDIR /app | |
COPY package*.json ./ | |
RUN npm install --production | |
COPY index.js ./ | |
CMD ["node", "index.js"] | |
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
const app = require("express")(); | |
const PORT = 3000; | |
app.listen(PORT, () => { | |
console.log(`Server running on port ${PORT}`); | |
}); | |
app.get("/", (req, res, next) => { | |
res.json({ | |
user: "john doe", | |
DB_URL: process.env.MYAPP_DB_URL, | |
OTHER_URL: process.env.MYAPP_OTHER_URL, | |
}); | |
}); |
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
{ | |
"name": "depency-docker-js", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"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