Skip to content

Commit

Permalink
Dockerize Application
Browse files Browse the repository at this point in the history
  • Loading branch information
Amnish04 committed Apr 9, 2024
1 parent 7c5e564 commit f3d2a1c
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Files to ignore from the build context
.github/
.vscode/

.git/
.gitignore
.prettier*
README.md

# No generated artifacts
dist/
node_modules/
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
###################################################################################################################
### STAGE 0: Install Dependencies ###
FROM node:20.9.0-bullseye@sha256:33e271b0c446d289f329aedafc7f57c41b3be1429956a7d1e174cfce10993eda AS dependencies
WORKDIR /app

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

# Clean install node dependencies defined in package-lock.json excluding dev dependencies
RUN npm ci --legacy-peer-deps

###################################################################################################################

### STAGE 1: Build ###
FROM node:20.9.0-bullseye@sha256:33e271b0c446d289f329aedafc7f57c41b3be1429956a7d1e174cfce10993eda AS build

WORKDIR /app

# Copy the generated dependenices
COPY --from=dependencies /app /app

# Copy source code
COPY . .

# Build the application
RUN ["npm", "run", "build"]

###################################################################################################################

### STAGE 2: Deploy ###
FROM nginx:1.24.0-alpine@sha256:62cabd934cbeae6195e986831e4f745ee1646c1738dbd609b1368d38c10c5519 as deploy

# Project Metadata
LABEL maintainer="Amnish Singh Arora <[email protected]>"\
description="Dine-A-Night restaurant table reservation web application."

# COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build /app/dist/dine-a-night-ui /usr/share/nginx/html

# Nginx uses the port 80
EXPOSE 80

# Add a healthcheck layer
HEALTHCHECK --interval=10s --timeout=10s --start-period=10s --retries=3 \
CMD curl --fail localhost:80 || exit 1

###################################################################################################################
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# docker-compose.yml

services:
# Dine-A-Night Web Application UI
dine-a-night:
container_name: dine-a-night
# Use a proper init process (tini)
init: true
# Build the Docker Image using the Dockerfile
# and current directory as the build context
build: .

# Ports to publish
ports:
- "4200:80"
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dine-a-night-ui",
"version": "0.8.0",
"version": "0.9.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand Down

0 comments on commit f3d2a1c

Please sign in to comment.