Skip to content

Deployment from local machines

How to Deploy from a Local Machine

The deployment process from your local machine includes just a few steps:

  1. Upload code to your server using the 'scp' command. 'scp' comes pre-installed with any OS that supports 'ssh', so no need to install additional tools. A key advantage of 'scp' is that it uses SSH keys for authentication, which you already have, so you won’t need to deal with extra keys or login credentials (unlike FTP or other upload protocols).

  2. Start the service or app on the server with your preferred tool to manage services/apps (as discussed in the "Prepare Project" chapter).

  3. Connect a domain to your service/app.

It’s a simple process—you don’t even need Git inside your project folder to deploy. Once you finish these three steps, your project will be online with a custom domain, automated TLS certificates (HTTPS and WSS), and auto-restarting in case of crashes or server reboots.

Steps to Deploy from a Local Folder

Before starting the deployment, ensure that: - Your project is ready to be deployed (as covered in the "Prepare Project" chapter). - Your domain has an A record pointing to your server’s public IP address (discussed in the "DNS Records" chapter). - You’re using a server with Ubuntu 22.04 and the required tools from the "Installation or Server Provision" chapter are installed.

Let’s assume the following: - The server's public IP address is 168.119.109.31 (replace it with your server’s IP in the commands below). - The default user on the server is root. - The domain is demo.turbocloud.dev. - Your local folder with source files is named demo_app and is located in your home directory. - Your service/app runs on port 4004.

Step 1: Upload Code to the Server

scp -r ~/demo_app root@168.119.109.31:demo_app

Step 2: SSH into the Server

ssh root@168.119.109.31

Step 3: Start Your App/Service

If you use Dockerfile (replace '~/demo_app' with your project folder name, and '4004' with your app’s port):

sudo docker build ~/demo_app -t demo_app_image
sudo docker container rm demo_app_container --force
sudo docker run -it -d --restart unless-stopped --name demo_app_container -p 4004:4004 demo_app_image

If you use systemd, confirm that you can start your app/service with the start script from the "Prepare Project" chapter. If the command sh ~/demo_app/start.sh runs without errors, follow these steps to create a systemd service file and start your app/service:

sudo echo -e "[Unit]\nDescription=DemoApp Agent\nWants=basic.target network-online.target nss-lookup.target time-sync.target\nAfter=basic.target network.target network-online.target" >> /etc/systemd/system/demo_app.service

sudo echo -e "[Service]\nSyslogIdentifier=demo_app\nExecStart=$HOME/demo_app/start.sh\nRestart=always" >> /etc/systemd/system/demo_app.service

sudo echo -e "[Install]\nWantedBy=multi-user.target" >> /etc/systemd/system/demo_app.service

sudo systemctl enable demo_app.service
sudo systemctl start demo_app.service

Step 4: Set Up a Proxy Server to Connect Your Domain

(Assuming the domain is demo.turbocloud.dev and your project uses port 4004):

sudo echo -e "demo.turbocloud.dev {\nreverse_proxy * localhost:4004\n}" >> /etc/caddy/Caddyfile
caddy reload -c /etc/caddy/Caddyfile

Step 5: Test Your App/Service

Wait 30-60 seconds, then open your app/service in a browser (in this case, at https://demo.turbocloud.dev). If everything went well, you should see your app/service live.

If the deployed project doesn’t work, go through the steps again. If it still doesn’t work, contact us at hey@turbocloud.dev with details of what you’re trying to achieve, the steps you’ve taken, and the errors you're encountering. The more information you provide, the faster we can help!