Sign inSign up

berkesayin/developing-with-containers

By berkesayin

Updated over 2 years ago

Image
0

598

berkesayin/developing-with-containers repository overview

Developing Application With Containers

This application includes

  • Containerized a Node.js application
  • Setting up a development environment
  • CI/CD pipeline for the application (GitHub actions)
  • Using Node.js application with Postgres image as db service with compose configuration
  • Using dpage/pgadmin4 container as PosgtreSQL UI.

GitHub repository with GitHub Actions workflow for CI/CD: https://github.com/berkesayin/developing-with-containers

The image berkesayin/developing-with-containers is built and published using GitHub Actions workflow at the repository. The image is the UI app of todo-server. And here is the usage of this berkesayin/developing-with-containers image with Postgres image for db service using compose configuration.

Usage

compose.yaml file:

version: "3.4"

services:
  server:
    platform: linux/x86_64
    image: berkesayin/developing-with-containers:latest
    container_name: todo-server-c
    ports:
      - 3000:3000
      - 9229:9229
    environment:
      NODE_ENV: production
      POSTGRES_HOST: db
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD_FILE: /run/secrets/db-password
      POSTGRES_DB: example
    depends_on:
      db:
        condition: service_healthy
    secrets:
      - db-password
    networks:
      - todo-network
  db:
    image: postgres
    container_name: postgres-db-c
    restart: always
    user: postgres
    secrets:
      - db-password
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=example
      - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
      - POSTGRES_HOST_AUTH_METHOD=md5 
      - PGDATA=/var/lib/postgresql/data/pgdata 
    expose:
      - 5432
    ports:
      - "5432:5432"
    healthcheck:
      test: [ "CMD", "pg_isready" ]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - todo-network
volumes:
  db-data:
secrets:
  db-password:
    file: db/password.txt
networks:
  todo-network:
    driver: bridge
Build And Run
docker-compose up --build
Images Pulled
docker images
Check containers
docker ps

Run PG Admin As A Container With Same Network (Optional)

Check The Network Name
docker network ls
Run PG Admin At Same Network With The App
docker run -p 8080:80 \                                                                                                                                                           
  -e '[email protected]' \
  -e 'PGADMIN_DEFAULT_PASSWORD=Resample-Landlady5-Bottle' \
  --network=trying_todo-network \
  --name=pgadmin-server-cont \
  -d dpage/pgadmin4
Add New Server For PG Admin

Go to localhost:8080/

  • General - Name: my-server
  • Connection - Hostname / address: db (db service at compose)
  • Connection - port: 5432 (the exposed and default PostgreSQL port at compose)
  • Connection - Maintanance database: example (db name at compose)
  • Connection - Username: postgres (db user at compose)
  • Connection - Password: Resample-Landlady5-Bottle (used for container)

Add new items at localhost:3000/ and check database at the PG admin.

Tag summary

Content type

Image

Digest

sha256:b12e36557

Size

68.7 MB

Last updated

over 2 years ago

docker pull berkesayin/developing-with-containers