Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate postgres to ztnet container #195

Closed
wants to merge 13 commits into from
Closed

Conversation

sinamics
Copy link
Owner

@sinamics sinamics commented Oct 31, 2023

Based on #193

Pros

  • More elegant composer file
  • Easier for users to understand the configuration
  • Reduces network complexity by eliminating inter-container communication for database access.
  • Total downloaded data decreases with ~50MB. ( psql docker image overhead )
  • Full support for postgres env, same as orginal image https://hub.docker.com/_/postgres/

Cons

  • The integration of PostgreSQL into the ztnet will increase the build time in github action from 8 to 14min for both amd64 and arm64.
  • Ztnet image increases in size, compressed ~320MB, compared to ~180MB without postgres.
  • Update postgres would require new ztnet build.

Migration Placeholder

Migration Guide: Integrating PostgreSQL into ztnet in Docker Compose

Steps for Migration

1. Update Docker Compose File

Modify your 'docker-compose.yml' to reflect the new configuration.

Remove the PostgreSQL Service

  # postgres:
  #   image: postgres:15.2-alpine
  #   container_name: postgres
  #   restart: unless-stopped
  #   volumes:
  #     - postgres-data:/var/lib/postgresql/data
  #   environment:
  #     POSTGRES_USER: postgres
  #     POSTGRES_PASSWORD: postgres
  #     POSTGRES_DB: ztnet
  #   networks:
  #     - app-network

Update ztnet Service

Configure the 'ztnet' service to include PostgreSQL. Use the 'sinamics/ztnet_postgres' image. ( for testing )
Transfer the postgres-data volume to the ztnet service to preserve existing data continuity.

  ztnet:
    image: sinamics/ztnet:integrate_postgres-28aac98          <--- Testing Image
    # image: sinamics/ztnet
    container_name: ztnet
    working_dir: /app
    volumes:
      - zerotier:/var/lib/zerotier-one
      - postgres-data:/var/lib/postgresql/data   <--- Postgres volume 
    restart: unless-stopped
    ports:
      - 3000:3000
    environment:
     # POSTGRES_HOST: localhost                   <--- Can be removed, defaults to localhost 
     # POSTGRES_PORT: 5432                        <--- Can be removed, defaults to 5432
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: postgres
      NEXTAUTH_URL: "http:https://10.0.0.32:3000"
      NEXTAUTH_SECRET: "random_secret"
    networks:
      - app-network
    # links:                                     <--- Removed
    #   - postgres                               <--- Removed
    depends_on:
      - zerotier
      # - postgres                               <--- Removed

@sinamics sinamics marked this pull request as draft November 1, 2023 19:33
@sinamics sinamics marked this pull request as ready for review November 12, 2023 17:41
@sinamics sinamics changed the title Integrate postgres to main image Integrate postgres to ztnet container Nov 12, 2023
@sinamics
Copy link
Owner Author

sinamics commented Dec 4, 2023

Closing for now.

@sinamics sinamics closed this Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant