Skip to content

Commit

Permalink
fix: Added default port ssh port 22 and forwarding of config port set…
Browse files Browse the repository at this point in the history
…ting (#6428)

* Added default port ssh port 22 and forwarding of config port setting

* Added port config option to documentation

* Correct typo in baremetal deployment docs

* Added expected default port to the default override test

* Added test for default port
  • Loading branch information
Josh-Walker-GM authored Sep 22, 2022
1 parent f937589 commit 8d3f60f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/docs/deploy/baremetal.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ This lists a single server, in the `production` environment, providing the hostn
#### Config Options

* `host` - hostname to the server
* `port` - [optional] ssh port for server connection, defaults to 22
* `username` - the user to login as
* `password` - [optional] if you are using password authentication, include that here
* `privateKey` - [optional] if you connect with a private key, include the content of the key here, as a buffer: `privateKey: Buffer.from('...')`. Use this *or* `privateKeyPath`, not both.
Expand Down Expand Up @@ -267,7 +268,7 @@ sudo mkdir -p /var/www/myapp
sudo chown deploy:deploy /var/www/myapp
```

You'll want to create an `.env` file in this directory containing any environment variables that are needed by your by your app (like `DATABASE_URL` at a minimum). This will be symlinked to each release directory so that it's available as the app expects (in the root directory of the codebase).
You'll want to create an `.env` file in this directory containing any environment variables that are needed by your app (like `DATABASE_URL` at a minimum). This will be symlinked to each release directory so that it's available as the app expects (in the root directory of the codebase).

:::caution SSH and Non-interactive Sessions

Expand Down
6 changes: 6 additions & 0 deletions packages/cli/src/commands/deploy/__tests__/baremetal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ describe('serverConfigWithDefaults', () => {

it('overrides defaults with custom', () => {
const serverConfig = {
port: 12345,
branch: 'venus',
packageManagerCommand: 'npm',
monitorCommand: 'god',
Expand All @@ -141,6 +142,11 @@ describe('serverConfigWithDefaults', () => {
expect(config).toEqual(serverConfig)
})

it('provides default port as 22', () => {
const config = baremetal.serverConfigWithDefaults({}, {})
expect(config.port).toEqual(22)
})

it('provides default branch name', () => {
const config = baremetal.serverConfigWithDefaults({}, {})
expect(config.branch).toEqual('main')
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/commands/deploy/baremetal.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const SYMLINK_FLAGS = '-nsf'
const CURRENT_RELEASE_SYMLINK_NAME = 'current'
const LIFECYCLE_HOOKS = ['before', 'after']
export const DEFAULT_SERVER_CONFIG = {
port: 22,
branch: 'main',
packageManagerCommand: 'yarn',
monitorCommand: 'pm2',
Expand Down Expand Up @@ -634,6 +635,7 @@ export const commands = (yargs, ssh) => {
task: () =>
ssh.connect({
host: serverConfig.host,
port: serverConfig.port,
username: serverConfig.username,
password: serverConfig.password,
privateKey: serverConfig.privateKey,
Expand Down

0 comments on commit 8d3f60f

Please sign in to comment.