Skip to content

Sample nodejs dockerized app - using envsubst to substitute variables in .env file with environment variables

Notifications You must be signed in to change notification settings

ch-benard/sample-node-docker-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sample-node-docker-app

This is a sample node application using envsubst to replace TEST and PORT variables contained in .env file by env variables.

These env variables can be set by:

docker run ... -e TEST="Some message" -e PORT=3000

The app is started by the command:

node app.js

contained in the start.sh script

To build the image:

docker build -t sample-node-docker-app:0.1

One way to execute the app is by running it with docker:

docker run -p 3000:9000 -e TEST="this is a message" -e PORT="9000" -ti sample-node-docker-app:0.1

Another way is to use docker-compose and a compose file:

docker-compose.yml:

version: "3.4"

services:
  api:
    image: sample-node-docker-app:0.1
    container_name: sample-node-app
    ports:
      - "3000:9000"
    environment:
      - TEST=Hello World for the first time!
      - PORT=9000

This work is mainly inspired by this repo. I just added the docker-compose way to start the app.

About

Sample nodejs dockerized app - using envsubst to substitute variables in .env file with environment variables

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published