Node JS, Docker and production mode on EC2

Sebastian Velez Zuluaga
1 min readJul 23, 2022

This is the next step to use docker on development enviroment.

I will use docker-compose because I need create some images one for develop and debug the app and the other to publish one a server EC2.

The steps are:

  1. Create and account on amazon.
  2. Create and EC2 Instance I am using Ubuntu 20 maybe the amazon instances are good.

3. Create a docker compose very importar use the same port to expose and run you app (env viarbales)

My comopose file:

If your app need some enviroment variables from SO (Ubunto) check the eviromente key.

4. Create a docker file with to images, develop and production.

5. Check your packge.json and be sure that whole packgre are there. I am using dotenv and cross-env

6. I crate a start commando to run my app, maybe in the future I will make some scrips more to build and test my app.

7 . To create your image run :

$ docker-compose up <name of service — docker compose file>

that’s all folks.

--

--