The Effortless Deployment Tool for the Lazy Developer. Deploy your development environment straight to prod only in one command. Under the hood Mager use docker swarm to orchestrate your container.
Current supported OS
- Linux
- MacOS
- Windows via WSL
- mkcert (need when you use mager in local)
- docker
curl https://raw.githubusercontent.com/praswicaksono/mager-deploy/refs/heads/master/install.sh | sh
Instead of docker-compose.yaml
, Mager have their own definition called mager.yaml
, Mager will read this configuration to build and deploy your application. Here is complete example of mager.yaml
name: project-name
build:
image: someimage # this image required this will be used as image name when pushed to registry
target: frankenphp_prod
context: .
services:
service-name:
cmd: ['php', '-v']
option:
limit_cpu: 0.25
limit_memory: 512MB
execute_once: # will execute on first deploy
- echo '1'
before_deploy: # will execute each time before deploy
- echo '1'
after_deploy: # will execute each time after deploy
- echo '1'
hosts:
- host.docker.internal:host-gateway
volumes:
- ./:/app
env:
SERVER_NAME: ${SERVER_NAME:-:80}
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
MERCURE_URL: ${CADDY_MERCURE_URL:-https://symfony-demo.wip/.well-known/mercure}
MERCURE_PUBLIC_URL: ${CADDY_MERCURE_PUBLIC_URL:-https://symfony-demo.wip/.well-known/mercure}
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
proxy:
ports:
- 80/tcp
rule: Host(`{$host}`) && Path('/') # ${$host} is placeholder, it will replace by value of host attribute
host: demo-app.com
Note: build.image
will be pulled from registry instead of building from Dockerfile when Dockerfile not exist
Mager not just for deployment, it can be used to replicate your production environment to your local environment. Everything works in local should also work in production.
Once you init your project, you can generate Mager definition based on template that selected
mager init
First you need to add entry your host that you have defined in mager.yaml
to system host file
sudo echo '127.0.0.1 demo-app.com' >> /etc/hosts
The run deployment
mager dev
It will install proxy
and TLS certificate using mkcert
.
Add mkcert
root CA to system certificate store
CAROOT=~/.mager/certs mkcert -install
Before you deploy to production, first you have to create namespace
.
Namespace
here is a set of servers within same network. You can add same server in different namespace
but application that deployed will have different network.
mager namespace:add <your-namespace>
It will prompt you few question for server credentials.
WARNING! For now Mager
have limitation can only deploy on single server
Then you have to prepare namespace
, it will setup docker swarm, creating network and install proxy.
mager prepare <your-namespace>
And at last you can deploy your service to specific namespace
mager deploy <your-namespace>