This repository is a POC for setting up and containerizing an express server
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
public/stylesheets
routes
views
.dockerignore
.gitignore
Dockerfile
LICENSE
README.md
app.js
package-lock.json
package.json

README.md

Containerizing an Express server.

This repository is a step by step guide for setting up and containerizing an express server. This repository also serves as a complementary guide for this article.

Environment Setup

Steps

  1. Create a folder
  2. Open a terminal and initial NPM on the folder.
npm init -y
  1. Install express-generator
npm install express-generator -g
  1. Bootstrap application skeleton
express --view=pug
  1. Install express server dependencies
npm install
  1. Add a docker file from iron/node
FROM iron/node
WORKDIR /app

# Copy package.json + package-lock.json files
COPY package*.json ./

# Installing dependencies
RUN npm install

# Bundle app source
COPY . .

EXPOSE 3000

ENTRYPOINT [ "npm", "start" ]
  1. Add the .dockerignore file below
node_modules
npm-debug.log
  1. Create a docker image by executing the command below on your app folder.
docker build --tag express/iron-api .
  1. Verify that your docker image was built.
docker images --all
  1. Instantiate a container out of the image you created.
docker run -p 3000:3000 --name iron-api express/iron-api
  1. Open the following link on a browser. http://localhost:3000/