Skip to content

Commit 16416e3

Browse files
authored
Merge pull request #4 from Sammyjo20/feature/documentation
Feature | Production Docs
2 parents eec9a73 + e4d1586 commit 16416e3

File tree

3 files changed

+75
-5
lines changed

3 files changed

+75
-5
lines changed

.github/README.md

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,78 @@ This will run the SSH server in your terminal window. In another window you shou
8080
ssh localhost -p 2201
8181
```
8282

83-
# Deploying to production
83+
## Deploying to production
8484

85-
### Credits
85+
### Requirements
86+
Your server must have Docker installed.
8687

88+
### Configuring Everything
89+
Firstly, copy the `docker-compose.yml` file to `docker-compose.prod.yml` and open it up. Inside here, change the ports from `2201:22` to `22:22`. This will mean on production your app will run on the regular SSH port.
90+
You may also need to define the platform to build on.
91+
92+
### Changing the default OpenSSH port on your server
93+
Next, we're going to need to change the OpenSSH port on your server to something other than `22`, because that's what our application will be running on. On your server run:
94+
95+
```
96+
sudo nano /etc/ssh/sshd_config
97+
```
98+
99+
Look for the line that starts with Port. It may be commented out, go ahead and uncomment it. Change it to whatever number you'd like (and is available), for example 2201. Then restart the service with the following command
100+
101+
```
102+
sudo service ssh restart
103+
```
104+
105+
Now you want to update your firewall rules to ensure that the port is not blocked. Depending on which firewall you are using, this may be different for you. For ufw:
106+
107+
```
108+
sudo ufw allow 2201/tcp
109+
```
110+
> [!CAUTION]
111+
> Important: Before you log out of the server or close that terminal tab, open a new terminal and make sure you can access your server via SSH. If it doesn't work you will be locked out of your server, so remaining logged in in the original tab will allow you to remedy any issues.
112+
113+
Next time you need to SSH into your server you can specify the custom port.
114+
115+
```
116+
sssh user@your-server -p 2201
117+
```
118+
119+
If you're using [Laravel Forge](https://forge.laravel.com) on this server, make sure you change the port that Forge connects to the server with under Settings > Server Settings > SSH Port.
120+
121+
### Clone your project onto the server
122+
Make sure you commit your `docker-compose.prod.yml` file and then deploy the whole project to your server.
123+
124+
### Deploy time!
125+
Now you can run the following command on your server. Run the following `./deploy.sh` script.
126+
127+
If it is the first time running the above deploy script, you may need to make it executable.
128+
129+
```
130+
chmod u+x ./deploy.sh
131+
```
132+
133+
```
134+
./deploy.sh
135+
```
136+
> If you are using Laravel Forge, you can add this to your deployment script to automatically update the SSH app.
137+
138+
It's completely normal for this command to exit after running. If you want to check that the Docker container is running, you can run the following command
139+
140+
```
141+
docker ps
142+
```
143+
## And that's it! ✨
144+
Now you can SSH into your server `ssh your-server-ip` and you should see your awesome PHP application! You can even point your DNS to the server IP and use that too if you like.
145+
146+
```
147+
ssh your-server-ip
148+
```
149+
150+
## Support
151+
If you found this project useful, please consider sponsoring me either one time or a regular sponsor. This helps pay myself for my time maintaining and keeping projects like these active. You can sponsor me on GitHub by [clicking here](https://github.com/sponsors/sammyjo20).
152+
153+
## Credits
87154
- Huge thanks to [Joe Tannenbaum's](https://joe.codes/) for his awesome [blog post](https://blog.joe.codes/creating-ssh-apps-with-charm-wish-and-laravel-prompts) and his support via Twitter/X DMs!
155+
156+
## Security
157+
If you find any security related issues, please send an email to [email protected]

composer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@
4747
],
4848
"run-dev": [
4949
"docker-compose up --build"
50-
],
51-
"deploy": [
52-
"docker-compose up -d --build"
5350
]
5451
}
5552
}

deploy.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker compose -f docker-compose.prod.yml up -d --build

0 commit comments

Comments
 (0)