Digital Ocean - checkout files on a docker server

After you have submitted your website files to SVN / GIT
-> this explains how to export those files to your server, restart docker and go LIVE

# 1 > Submit your files on your computer

Commit your files like you normally do to SVN or GIT

# 2 > Install SSH public key (FIRST TIME ONLY)

By adding YOUR public ssh key to the SERVER, this will allow you to connect WITHOUT a password. 

If you never setup SSH on your computer run the following command

ssh-keygen -t rsa -b 4096

Next open terminal and run this command that will copy to your clipboard your PUBLIC key and send to your administrator

pbcopy < ~/.ssh/id_rsa.pub

OR if the copy does not work - manually run this command in terminal and right-click copy and paste to your administrator

cat ~/.ssh/id_rsa.pub

run this command from your terminal program
-> then double click on the long line and copy
-> Email this public key to the personal administering the server
-> After they install you will be able to logon withou a password

# 3 > Logon to your server via SSH

Next logon to your server with SSH

ssh root@123.456.789.222

You can get your ip address from the control panel of Digital Ocean 

# 4 > Create checkout script (FIRST TIME ONLY)

Now we are going to create our script which will do the following:
- Checkout all the files on your server
- Restart docker / initiate docker for the first time

vi checkout-restart-docker.sh
-> and paste the info below

#!/usr/bin/env bash
rm -rf /var/www/live/*
svn export --force https://svn.undologic.com/updateCase.com/undoWebShared/trunk/. /var/www/live/. --username readonly

#very unsecure for now ONLY FOR TESTING - DO NOT USE ON PROD
chmod 777 /var/www/live -R
#chmod 777 -R /var/www/live/app/tmp
#touch /var/www/live/app/webroot/updateCase.log
#chmod 777 -R /var/www/live/app/webroot/updateCase.log

#restasrt docker
cd /var/www/live/docker/
docker-compose down
sleep 5
docker-compose up -d

# 5 > go LIVE

To upgrade the server to the latest version of the files
-> Simply run this command


The website is now LIVE
-> All the changes that were submitted to SVN / GIT are now live
-> And docker is restarted

# 6 > Upload directly - Remote

If you prefer to upload directly using PHP storm

- Tools
- Deployement
- Remote Host


# 7 > Upload Directly - configure

Click the three dots
TYPE: choose SFTP
HOST: what people type to see your website
USER NAME: from digital ocean
AUTHENTICATION: Key pair OpenSSH or Putty
PRIVATE KEY FILE: click to browse to ~/.ssh/id_rsa.pub
PASSPHRASE: only if you setup a passphrase when you setup ssh on your computer
ROOT PATH: Click auth detect to set

# 8 > Upload Directly - Paths

Now we need to set what path on your computer relates to the path on the server

Click the 2 small browse icons on the right side and navigate to ensure your locale computer website files matches to the server

DEFAULT: the server normally uses /var/www/live