Skip to content

FEA505 - Configure scalable and resilient infrastructure using containerization

Feature ID FEA505
Subsystem the feature is part of EP05 - Frontend/Backend
Responsible person Matias Korpela
Status Implemented

Description

Through this functionality, our goal is to encapsulate our service within Docker, ensuring that both its dependencies and configuration are bundled together into a container image. The frontend and backend will have their own images.

ID Description
FUNC-REQ-C0006 You have to be able to dockerize the software

Preliminary user stories

  • US027 As a platform engineer, I want to set up a scalable and resilient infrastructure using containerization, such as Docker, to ensure easy deployment and management of the web app., Dockerize everything. #69

User interface mock-up

Implementation

Docker was used for containerization. Containers run at our own CSC instances. Architecture for CSC deployment can be seen on Architecture and Design

Frontend DOCKERFILE

FROM node:20-alpine as build
ARG BUILD_MODE=production
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm i
COPY . .

COPY .env.${BUILD_MODE} ./.env

RUN npm run ${BUILD_MODE}-build

FROM nginx:latest
COPY --from=build /app/dist /usr/share/nginx/html

Backend

DOCKERFILE
FROM node:alpine as build
WORKDIR /app
COPY package.json package-lock.json tsconfig.json ./
RUN npm i --omit-dev
COPY . ./
RUN npm run build

FROM node:alpine
WORKDIR /app
COPY --from=build /app/dist/ ./
COPY --from=build /app/node_modules ./node_modules
# In production, the env file should be copied with custom values
COPY .env ./.env
CMD ["node", "./index.js"]
docker-compose
version: "3.8"
services:
  redis-stack:
    image: redis/redis-stack:latest
    container_name: tukko-redis
    restart: always
    ports:
      - 6379:6379
    volumes:
      - ./redis-stack.conf:/redis-stack.conf

  mongo:
    image: mongo:jammy
    container_name: tukko-archive
    env_file:
      - .env

  tv-api:
    depends_on:
      - redis-stack
      - mongo
    image: ${DOCKER_IMAGE_NAME}
    container_name: tukko-app
    restart: always
    environment:
      REDIS_OM_URL: "redis://redis-stack:6379"
      DB_CONN_STRING: "mongodb://admin:admin@mongo:27017"
    ports:
      - "3001:3001"

Testing / possible acceptance criteria

Testcase Test source Responsible
Testcase 1 FUNC-REQ-C0006 Ops