Skip to content

Instantly share code, notes, and snippets.

@mimiz
Created December 19, 2020 09:16
Show Gist options
  • Save mimiz/69502dcd69318e1f9d9cfa823610462e to your computer and use it in GitHub Desktop.
Save mimiz/69502dcd69318e1f9d9cfa823610462e to your computer and use it in GitHub Desktop.
node-simple-exemple-inject-vars-with-docker
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"]
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,
});
});
{
"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