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

Syntax for multiple deployment targets #25

Closed
Starraider opened this issue Nov 29, 2023 · 2 comments · Fixed by #33
Closed

Syntax for multiple deployment targets #25

Starraider opened this issue Nov 29, 2023 · 2 comments · Fixed by #33

Comments

@Starraider
Copy link

In many projects, it is common to have a separate staging server and production server.
Until now, I have always solved this in Deployer:

host('live')
    ->hostname('pxxxxx.mittwaldserver.info')
    ->user('pxxxxx')
    ->set('branch', 'main')
   ...
host('staging')
    ->hostname('pyyyyy.mittwaldserver.info')
    ->user('pyyyyy')
    ->set('branch', 'develop')
   ...

This way you could easily choose, if you want to deploy to the live or staging server by /vendor/bin/dep deploy live

With your Mittwald deployer-recipes, however, it is not clear to me what the syntax must look like here in order to be able to distinguish between two servers!
How can I set different "names" for the servers in the mittwald_app('<app-id>')?

@martin-helmich
Copy link
Member

In this case, I'd recommend creating two separate apps for each environment (staging+prod), which may or may not run within the same project.

You probably won't be able to use the mittwald_app shorthand function in this case (because it hardcodes the hostname to mittwald -- something that we could actually make configurable, now that I think about it 🤔), since deployer will then treat those as a single host. Instead, you can still define the hosts using the regular host(...) function, and then set the mittwald_app_id variable for each host.

host('mittwald-prod')
    ->set('mittwald_app_id', '<app-id-prod>')
    ->set('branch', 'main');

host('mittwald-staging')
    ->set('mittwald_app_id', '<app-id-staging>')
    ->set('branch', 'develop');

Let me know if that helps!

@martin-helmich
Copy link
Member

Quick update: With #33, you now have the option to overwrite the hostname when using the mittwald_app shorthand function:

mittwald_app('<app-id-prod>', hostname: 'mittwald-prod')
    ->set('branch', 'main');
mittwald_app('<app-id-staging>', hostname: 'mittwald-staging')
    ->set('branch', 'develop');

I've also added a short section on deploying to multiple environments in the respective documentation: mittwald/developer-portal#62.

I hope that helps; I'll close this issue for now -- feel free to reopen. 🙂

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 a pull request may close this issue.

2 participants