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

feat: Add Support for Alternative Container Runtimes (Podman, containerd) #1682

Open
zvictor opened this issue Feb 9, 2025 · 1 comment
Open

Comments

@zvictor
Copy link
Contributor

zvictor commented Feb 9, 2025

Description:

Please add support for alternative container runtimes like Podman and containerd to trigger.dev. This will make the tool more flexible and accessible to a wider range of users. Some users prefer Podman for rootless execution, or use containerd in Kubernetes environments.

Problem:

Currently, trigger.dev requires Docker, which isn't ideal for everyone. Current blockers include:

Proposed Solution:

Allow users to specify their preferred container runtime. This could be done with:

  • An environment variable (e.g., TRIGGER_CONTAINER_RUNTIME=podman).
  • A setting in a config file.

The CLI would then use this setting instead of directly calling docker.

Relevant Discussions:

@zvictor
Copy link
Contributor Author

zvictor commented Feb 9, 2025

These are the changes I had to make to https://github.com/triggerdotdev/docker in order to work with Podman with relative success:

diff --git a/docker-compose.worker.yml b/docker-compose.worker.yml
index 477e0b6..c3abbc6 100644
--- a/docker-compose.worker.yml
+++ b/docker-compose.worker.yml
@@ -12,7 +12,7 @@ services:
     image: ghcr.io/triggerdotdev/provider/docker:${TRIGGER_IMAGE_TAG:-v3}
     restart: ${RESTART_POLICY:-unless-stopped}
     volumes:
-      - /var/run/docker.sock:/var/run/docker.sock
+      - $XDG_RUNTIME_DIR/podman/podman.sock:/var/run/docker.sock
     user: root
     networks:
       - default
@@ -28,7 +28,7 @@ services:
     image: ghcr.io/triggerdotdev/coordinator:${TRIGGER_IMAGE_TAG:-v3}
     restart: ${RESTART_POLICY:-unless-stopped}
     volumes:
-      - /var/run/docker.sock:/var/run/docker.sock
+      - $XDG_RUNTIME_DIR/podman/podman.sock:/var/run/docker.sock
     user: root
     networks:
       - default
diff --git a/docker-compose.yml b/docker-compose.yml
index 424f912..8043dcb 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -19,6 +19,8 @@ networks:
 
 services:
   webapp:
+    name: trigger-network
+    driver: bridge
     image: ghcr.io/triggerdotdev/trigger.dev:${TRIGGER_IMAGE_TAG:-v3}
     restart: ${RESTART_POLICY:-unless-stopped}
     env_file:
@@ -28,8 +30,10 @@ services:
     ports:
       - ${WEBAPP_PUBLISH_IP:-127.0.0.1}:3040:3030
     depends_on:
-      - postgres
-      - redis
+      postgres:
+        condition: service_healthy
+      redis:
+        condition: service_started
     networks:
       - webapp
 
@@ -47,6 +51,15 @@ services:
     command:
       - -c
       - wal_level=logical
+      - -c
+      - fsync=off
+      - -c
+      - full_page_writes=off
+    healthcheck:
+      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB:-postgres}"]
+      interval: 5s
+      timeout: 5s
+      retries: 10
 
   redis:
     image: redis:${REDIS_IMAGE_TAG:-7}
@@ -59,10 +72,13 @@ services:
       - ${DOCKER_PUBLISH_IP:-127.0.0.1}:6389:6379
 
   docker-provider:
     image: ghcr.io/triggerdotdev/provider/docker:${TRIGGER_IMAGE_TAG:-v3}
     restart: ${RESTART_POLICY:-unless-stopped}
     volumes:
-      - /var/run/docker.sock:/var/run/docker.sock
+      - $XDG_RUNTIME_DIR/podman/podman.sock:/var/run/docker.sock
     user: root
     networks:
       - webapp
@@ -80,7 +96,7 @@ services:
     image: ghcr.io/triggerdotdev/coordinator:${TRIGGER_IMAGE_TAG:-v3}
     restart: ${RESTART_POLICY:-unless-stopped}
     volumes:
-      - /var/run/docker.sock:/var/run/docker.sock
+      - $XDG_RUNTIME_DIR/podman/podman.sock:/var/run/docker.sock
     user: root
     networks:
       - webapp
@@ -98,10 +114,29 @@ services:
     image: electricsql/electric:${ELECTRIC_IMAGE_TAG:-latest}
     restart: ${RESTART_POLICY:-unless-stopped}
     environment:
-      DATABASE_URL: ${DATABASE_URL}?sslmode=disable
+      DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/postgres?sslmode=disable"
     networks:
       - webapp
     depends_on:
-      - postgres
+      postgres:
+        condition: service_healthy
     ports:
       - ${DOCKER_PUBLISH_IP:-127.0.0.1}:3061:3000
diff --git a/lib.sh b/lib.sh
index 660801f..0131db0 100644
--- a/lib.sh
+++ b/lib.sh
@@ -1,12 +1,12 @@
 #!/bin/sh
 
 docker_compose() {
-    if docker compose >/dev/null 2>&1; then
+    if podman compose >/dev/null 2>&1; then
         set -x
-        docker compose "$@"
-    elif command -v docker-compose >/dev/null 2>&1; then
+        podman compose "$@"
+    elif command -v podman-compose >/dev/null 2>&1; then
         set -x
-        docker-compose "$@"
+        podman-compose "$@"
     else
         echo Please install docker compose: https://docs.docker.com/compose/install/
     fi
diff --git a/start.sh b/start.sh
index 16a8b68..2f0402c 100755
--- a/start.sh
+++ b/start.sh
@@ -55,4 +55,4 @@ else
     extra_args="-p=trigger-$kind"
 fi
 
-docker_compose -f "$compose_file" "$extra_args" up "$@"
+docker_compose -f "$compose_file" "$extra_args" up "$@" --build

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

No branches or pull requests

1 participant