Skip to content

Starter project for a dockerized MEAN webapp (+Typescript). Provides zero downtime development and debugging.

Notifications You must be signed in to change notification settings

alex-gru/docker-mean-ts-starter

Repository files navigation

Starter project for a dockerized MEAN webapp (+Typescript)

This repository provides an out-of-the-box environment for a fully dockerized web application.

Application Stack

image

  • Docker, docker-compose container platform, orchestration
  • Typescript code frontend, backend
  • MongoDB document database
  • Express web server
  • AngularJS frontend js/ts framework
  • Node.js backend
  • Pug template engine, used for Angular component templates

Call for PRs regarding Angular upgrade

With this established environment, I could not get Angular (4) running, so I use AngularJS for now. Any ideas would be appreciated - just create a PR.

Features

zero downtime development with Docker, hot code reload, browser auto-refresh, debugging

Prerequisites

Docker and Docker Compose are necessary.

Build & Run

First, install dependencies locally.

npm install

Now, we use docker-compose for orchestration of the 3 docker containers used:

  • web is the node.js web server (based on the slim mhart/alpine-node)
  • mongo is the mongoDB database (based on mongo)
  • mongo-import feeds the db in mongo with some dummy data (see sub-directory mongo-import, also based on mongo)

Environments

To separate development features from the actual application, three docker-compose configs are used.

  • base.yml is the base config

  • dev.yml should only be used for development environment, since it mounts the project directory, starts file watchers, enables auto-restarts and exposes debugging ports

  • prod.yml production-safe config

Run Production

docker-compose -f compose-base.yml -f compose-prod.yml up

Run Dev

docker-compose -f compose-base.yml -f compose-dev.yml up --build

-build rebuilds the image if changes are detected

optional: -d makes the container running in the background (use docker stop to stop)

Display the app in your browser

http://localhost:8080

Debug the dockerized node.js application

The repository contains a debug configuration which you can use with WebStorm for example. See more details about remote node.js debugging here