Skip to main content

Static HTML Server Container

Serve a static site’s ‘/dist’ directory (e.g. built Angular, React, or Vue SPA ‘/dist’ directory).

Docker Compose Commands

Build container

docker-compose up -d --build

Run previously built container

docker-compose up

Stop running container

docker-compose stop

Dockerfile

FROM node:lts-alpine

# install simple http server for serving static content
RUN npm install -g http-server

# make the 'app' folder the current working directory
WORKDIR /app

# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . .

# expose the port
EXPOSE 8080

# start the server
CMD [ "http-server", "dist" ]

.dockerignore

node_modules
build
.dockerignore
Dockerfile
Dockerfile.prod

docker-compose.yml

version: '3.7'

services:
your-project-name:
container_name: docker-container-name
build:
context: .
dockerfile: Dockerfile
image: docker-container-name:dev
volumes:
- '.:/usr/src/app'
ports:
- 8080:8080