Allow multiple apps to be deployed to the same server #137
Replies: 2 comments 1 reply
-
Been waiting for this!!!! 🎉 (And InertiaJS SSR as well 🤣) |
Beta Was this translation helpful? Give feedback.
-
My goal today was to get a better post put together, but I had a discussion with @harrisonratcliffe today and figured I would share these very quick notes. There is a chance as some of you chime in, I will put this into a better form of documentation and/or video. Background & TL;DRI plan to automate and simplify this process natively in Spin, but it will take time to do this correctly. Instead of waiting I wanted to share notes that it is possible to run multiple apps on a single server with Docker Swarm (what Spin uses) today. If you feel like tinkering, follow this quick guide. Important concepts
More about the concept is here: https://docs.docker.com/compose/how-tos/networking/#use-an-existing-network Deploy and app with SpinRun a usual deployment. It will have Traefik. Create a 2nd appYou can create another app. It will have Traefik in the Important If you try to deploy Traefik to the same server, it will fail because another service is already using Adjust networks on the new appYou'll see in the services:
php:
image: ${SPIN_IMAGE_DOCKERFILE_PHP}
networks:
- web-public We don't want to use Instead, SSH into your server and run So in our 2nd app, we want to change that network to EXACTLY MATCH and ALSO DECLARE that services:
php:
image: ${SPIN_IMAGE_DOCKERFILE_PHP}
networks:
- spin_web-public
networks:
spin_web-public:
external: true
Important Make sure you update both the Change the docker labels for TraefikThe next part is to get the Traefik configurations set, which is all done through The original labels look like this: labels:
- "traefik.enable=true"
- "traefik.http.routers.laravel-web.rule=Host(`${SPIN_APP_DOMAIN}`)"
- "traefik.http.routers.laravel-web.entrypoints=websecure"
- "traefik.http.routers.laravel-web.tls=true"
- "traefik.http.routers.laravel-web.tls.certresolver=letsencryptresolver"
- "traefik.http.services.laravel-web.loadbalancer.server.port=8443"
- "traefik.http.services.laravel-web.loadbalancer.server.scheme=https"
# Health check
- "traefik.http.services.laravel-web.loadbalancer.healthcheck.path=/up"
- "traefik.http.services.laravel-web.loadbalancer.healthcheck.interval=30s"
- "traefik.http.services.laravel-web.loadbalancer.healthcheck.timeout=5s"
- "traefik.http.services.laravel-web.loadbalancer.healthcheck.scheme=https" Notice a few key things here:
This means on your second app, you need to rename Again, make sure you're setting Run a deploymentDeploy that sh*t and hopefully it will work 🤠 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
👉 Describe the problem
Spin only supports one app stack to be deployed to a server.
👥 Problem evidence & reach
🥰 Describe the "impact" on users?
This could save some users money and complexity so they don't need to manage multiple servers.
🏆 How to solve this problem
Create a "Spin Proxy" variable
This could be something enabled in the
.spin.yml
where users could enable "multitenancy". This would have the Ansible playbook create a default proxy (like Traefik). Once that "global service" is running, then users can use external networks to join to the proxy: https://docs.docker.com/compose/how-tos/networking/#use-a-pre-existing-network💯 How do we validate the problem is solved?
Beta Was this translation helpful? Give feedback.
All reactions