Skip to content
New issue

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

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

Already on GitHub? # to your account

podlet compose --pod doesn't prepend requires with pod name #114

Closed
sugoidogo opened this issue Sep 29, 2024 · 2 comments · Fixed by #115
Closed

podlet compose --pod doesn't prepend requires with pod name #114

sugoidogo opened this issue Sep 29, 2024 · 2 comments · Fixed by #115
Labels
bug Something isn't working
Milestone

Comments

@sugoidogo
Copy link

I was using podlet to convert glitchtip's docker-compose file to a pod and found that the requires options weren't prepended with the pod name the same way that the container file names were. I had to make other changes to their compose file since they were taking advantage of the docker extension syntax to define their common options, so I've also included my edited version of the compose file to make it podlet-compatible.

[root@digitalocean ~]# cat glitchtip.yml
name: glitchtip
services:
  postgres:
    image: postgres:16
    environment:
      POSTGRES_HOST_AUTH_METHOD: "trust"  # Consider removing this and setting a password
    #restart: unless-stopped
    volumes:
      - /etc/glitchtip/pg-data:/var/lib/postgresql/data
  redis:
    image: redis
    #restart: unless-stopped
  web:
    image: glitchtip/glitchtip
    depends_on: &default-depends_on
      - postgres
      - redis
    ports:
      - "8000:8000"
    environment: &default-environment
      DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
      SECRET_KEY: change_me_to_something_random # best to run openssl rand -hex 32
      PORT: 8000
      EMAIL_URL: consolemail:// # Example smtp://email:password@smtp_url:port https://glitchtip.com/documentation/install#c>  EMAIL_BACKEND: anymail.backends.mailjet.EmailBackend
      DEFAULT_FROM_EMAIL: email@glitchtip.com # Change this to your email
      CELERY_WORKER_AUTOSCALE: "1,3"  # Scale between 1 and 3 to prevent excessive memory usage. Change it or remove to set>  CELERY_WORKER_MAX_TASKS_PER_CHILD: "10000"
    #restart: unless-stopped
    volumes: &uploads
      - /etc/glitchtip/uploads:/code/uploads
  worker:
    image: glitchtip/glitchtip
    command: ./bin/run-celery-with-beat.sh
    depends_on: *default-depends_on
    environment: *default-environment
    #restart: unless-stopped
    volumes: *uploads
  migrate:
    image: glitchtip/glitchtip
    depends_on: *default-depends_on
    command: ./bin/run-migrate.sh
    environment: *default-environment
[root@digitalocean ~]# podlet compose glitchtip.yml --pod
# glitchtip-postgres.container
[Container]
Environment=POSTGRES_HOST_AUTH_METHOD=trust
Image=postgres:16
Pod=glitchtip.pod
Volume=/etc/glitchtip/pg-data:/var/lib/postgresql/data

---

# glitchtip-redis.container
[Container]
Image=redis
Pod=glitchtip.pod

---

# glitchtip-web.container
[Unit]
Requires=postgres.service redis.service
After=postgres.service redis.service

[Container]
Environment=DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres SECRET_KEY=change_me_to_something_random PORT=8000 EMAIL_URL=consolemail:// DEFAULT_FROM_EMAIL=email@glitchtip.com CELERY_WORKER_AUTOSCALE=1,3
Image=glitchtip/glitchtip
Pod=glitchtip.pod
Volume=/etc/glitchtip/uploads:/code/uploads

---

# glitchtip-worker.container
[Unit]
Requires=postgres.service redis.service
After=postgres.service redis.service

[Container]
Environment=DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres SECRET_KEY=change_me_to_something_random PORT=8000 EMAIL_URL=consolemail:// DEFAULT_FROM_EMAIL=email@glitchtip.com CELERY_WORKER_AUTOSCALE=1,3
Exec=./bin/run-celery-with-beat.sh
Image=glitchtip/glitchtip
Pod=glitchtip.pod
Volume=/etc/glitchtip/uploads:/code/uploads

---

# glitchtip-migrate.container
[Unit]
Requires=postgres.service redis.service
After=postgres.service redis.service

[Container]
Environment=DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres SECRET_KEY=change_me_to_something_random PORT=8000 EMAIL_URL=consolemail:// DEFAULT_FROM_EMAIL=email@glitchtip.com CELERY_WORKER_AUTOSCALE=1,3
Exec=./bin/run-migrate.sh
Image=glitchtip/glitchtip
Pod=glitchtip.pod

---

# glitchtip.pod
[Pod]
PublishPort=8000:8000
@k9withabone
Copy link
Member

Good catch! I'll fix it for the next release. Support for fragments/anchors will also be part of the next release, see #58.

@sugoidogo
Copy link
Author

sugoidogo commented Nov 22, 2024

Podlet also doesn't seem to prepend the pod name for network units

[root@digitalocean ztnet]# cat docker-compose.yml
name: ztnet
services:
  postgres:
    image: postgres:15.2-alpine
    container_name: postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: ztnet
    volumes:
      - postgres-data:/var/lib/postgresql/data
    networks:
      - app-network

  zerotier:
    image: zyclonite/zerotier:1.14.0
    hostname: zerotier
    container_name: zerotier
    restart: unless-stopped
    volumes:
      - zerotier:/var/lib/zerotier-one
    cap_add:
      - NET_ADMIN
      - SYS_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    networks:
      - app-network
    ports:
      - "9993:9993/udp"
    environment:
      - ZT_OVERRIDE_LOCAL_CONF=true
      - ZT_ALLOW_MANAGEMENT_FROM=172.31.255.0/29

  ztnet:
    image: sinamics/ztnet:latest
    container_name: ztnet
    working_dir: /app
    volumes:
      - zerotier:/var/lib/zerotier-one
    restart: unless-stopped
    ports:
      - 3000:3000
    # - 127.0.0.1:3000:3000  <--- Use / Uncomment this line to restrict access to localhost only
    environment:
      POSTGRES_HOST: postgres
      POSTGRES_PORT: 5432
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: ztnet
      NEXTAUTH_URL: "http://sugoidogo.com:3000" # !! Important !! Set the NEXTAUTH_URL environment variable to the canonical URL or IP of your site with port 3000
      NEXTAUTH_SECRET: "random_secret"
      NEXTAUTH_URL_INTERNAL: "http://ztnet:3000" # Internal NextAuth URL for 'ztnet' container on port 3000. Do not change unless modifying container name.
    networks:
      - app-network
    depends_on:
      - postgres
      - zerotier

  ############################################################################
  #                                                                          #
  # Uncomment the section below to enable HTTPS reverse proxy with Caddy.    #
  #                                                                          #
  # Steps:                                                                   #
  # 1. Replace <YOUR-PUBLIC-HOST-NAME> with your actual public domain name.  #
  # 2. Uncomment the caddy_data volume definition in the volumes section.    #
  #                                                                          #
  ############################################################################

  # https-proxy:
  #   image: caddy:latest
  #   container_name: ztnet-https-proxy
  #   restart: unless-stopped
  #   depends_on:
  #     - ztnet
  #   command: caddy reverse-proxy --from <YOUR-PUBLIC-HOST-NAME> --to ztnet:3000
  #   volumes:
  #     - caddy_data:/data
  #   networks:
  #     - app-network
  #   links:
  #     - ztnet
  #   ports:
  #     - "80:80"
  #     - "443:443"

volumes:
  zerotier:
  postgres-data:
  # caddy_data:

networks:
  app-network:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.31.255.0/29
[root@digitalocean ztnet]# podlet compose --pod
# ztnet-postgres.container
[Container]
ContainerName=postgres
Environment=POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_DB=ztnet
Image=postgres:15.2-alpine
Network=app-network
Pod=ztnet.pod
Volume=postgres-data:/var/lib/postgresql/data

[Service]
Restart=always

---

# ztnet-zerotier.container
[Container]
AddCapability=NET_ADMIN SYS_ADMIN
AddDevice=/dev/net/tun:/dev/net/tun
ContainerName=zerotier
Environment=ZT_OVERRIDE_LOCAL_CONF=true ZT_ALLOW_MANAGEMENT_FROM=172.31.255.0/29
HostName=zerotier
Image=zyclonite/zerotier:1.14.0
Network=app-network
Pod=ztnet.pod
Volume=zerotier:/var/lib/zerotier-one

[Service]
Restart=always

---

# ztnet-ztnet.container
[Unit]
Requires=postgres.service zerotier.service
After=postgres.service zerotier.service

[Container]
ContainerName=ztnet
Environment=POSTGRES_HOST=postgres POSTGRES_PORT=5432 POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_DB=ztnet NEXTAUTH_URL=http://sugoidogo.com:3000 NEXTAUTH_SECRET=random_secret NEXTAUTH_URL_INTERNAL=http://ztnet:3000
Image=sinamics/ztnet:latest
Network=app-network
Pod=ztnet.pod
Volume=zerotier:/var/lib/zerotier-one
WorkingDir=/app

[Service]
Restart=always

---

# app-network.network
[Network]
Driver=bridge
IPAMDriver=default
Subnet=172.31.255.0/29

---

# ztnet.pod
[Pod]
PublishPort=9993:9993/udp
PublishPort=3000:3000

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants