-
Notifications
You must be signed in to change notification settings - Fork 36
Add hypernode-deploy documentation for Bitbucket pipelines #295
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
Merged
tdgroot
merged 3 commits into
ByteInternet:master
from
poespas:feature/add_docs_for_bitbucket_pipelines
Dec 6, 2024
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,101 @@ | ||
| # Bitbucket Pipelines | ||
|
|
||
| This article is currently work in progress! | ||
| ## Configuring deployment environments | ||
|
|
||
| To start using Bitbucket Pipelines, we need to prepare the environments we want to deploy to. | ||
|
|
||
| For example, these environments can be: | ||
|
|
||
| - production | ||
| - acceptance (or staging) | ||
| - test | ||
|
|
||
| ### Configuring the production environment | ||
|
|
||
| Hypernode Deploy will need a pair of SSH keys for authentication to the server. | ||
|
|
||
| First, we generate an SSH keypair on the production server, copy the public key to the `~/.ssh/authorized_keys` file | ||
| and encode the private key with base64. We'll use this base64-encoded private key later on. | ||
|
|
||
| ```console | ||
| app@abc-example-magweb-cmbl:~$ ssh-keygen -t ed25519 -C bb-pipelines-deploy -f bb-pipelines-deploy -q -P "" | ||
| app@abc-example-magweb-cmbl:~$ cat bb-pipelines-deploy.pub >> ~/.ssh/authorized_keys | ||
| app@abc-example-magweb-cmbl:~$ cat bb-pipelines-deploy | base64 -w0 # encode the private key with base64 | ||
| LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFBQUFBQkc1dmJtV... | ||
| ``` | ||
|
|
||
| Now go to your Bitbucket repository and enable Bitbucket pipelines being going to **Repository settings -> Pipelines -> Settings** and turn on **Enable Pipelines**. | ||
|
|
||
| Now go to **Repository settings -> Pipelines -> Repository variables**. | ||
|
|
||
| 1. Create a new variable with name `SSH_PRIVATE_KEY`, mark this variable as Secured. | ||
| 2. Set the **Value** to the base64-encoded private key we generated earlier. | ||
| 3. Click **Add**. | ||
|
|
||
| To add hosts to the Pipeline known hosts go to **Repository settings -> Pipelines -> SSH Keys** | ||
|
|
||
| 1. Set **Host address** to your hypernode instance (e.g. _appname.hypernode.io_) | ||
| 2. Click **Fetch** to fetch the hostname fingerprint | ||
| 3. Click **Add Host** to add host to known hosts | ||
| 4. Repeat this for all hosts the pipeline will connect to (for example production, staging) | ||
|
|
||
| ## Build | ||
|
|
||
| Create the file `bitbucket-pipelines.yml` with the contents below. | ||
| This workflow will be used in other workflows. | ||
|
|
||
| ```yaml | ||
| image: quay.io/hypernode/deploy:3-php8.2-node18 | ||
|
|
||
| definition: | ||
| steps: | ||
| - step: &hypernode-build | ||
| name: Build | ||
| script: | ||
| - hypernode-deploy build | ||
| artifacts: | ||
| - build/** | ||
| ``` | ||
| ````{note} | ||
| Don't forget to set the specifications of the image to what your project needs. The same goes for the deploy steps. | ||
| For example, if your project needs PHP 7.4 and Node.js 16, set the image to: | ||
| ```yaml | ||
| jobs: | ||
| build: | ||
| container: quay.io/hypernode/deploy:3-php7.4-node16 | ||
| ... | ||
| ``` | ||
| ```` | ||
| ## Deploy to production | ||
| Add the following to the `bitbucket-pipelines.yml` file. | ||
| ```yaml | ||
| pipelines: | ||
| # Deploy to production | ||
| master: | ||
| - step: *hypernode-build | ||
| - step: | ||
| name: Deploy to production | ||
| deployment: production | ||
| script: | ||
| - hypernode-deploy deploy production | ||
| ``` | ||
| ## Deploy to acceptance | ||
| If you have an acceptance (or staging) stage in your deployment flow, here's an example on how to deploy that. | ||
| ```yaml | ||
| pipelines: | ||
| # Deploy to acceptance | ||
| acceptance: # acceptance/staging branch | ||
| - step: *hypernode-build | ||
| - step: | ||
| name: Deploy to staging | ||
| deployment: staging | ||
| script: | ||
| - hypernode-deploy deploy staging | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitbucket Pipelines has a default keypair as well right? So perhaps good to clarify this is optional? I haven't verified if that works with Hypernode Deploy, though
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! It works without any ssh key variable if I generate one in the repository and add to the server, will reflect that to the docs.