WARNING: It is recommended for developers to understand containerization, docker setup and builds. Tradeoff here is, developer skills vs VM cost. If developer skills are not possible only options remains is to setup a vm for development. It is costlier because you are paying for a developer as well as a VM.
Before you begin, ensure you have the following:
- VSCode Installed: Download and install Visual Studio Code from the official website.
- SSH Client: Your system should have an SSH client installed (usually pre-installed on Linux/macOS; for Windows, you might need Git Bash or an OpenSSH client).
- Remote Server Access: You need access to a remote server with an IP address (e.g.,
1.2.3.4), a username (e.g.,ubuntu), and an SSH private key (.pemfile).
The Remote - SSH extension allows VSCode to connect to remote machines using SSH.
- Open Visual Studio Code.
- Go to the Extensions view by clicking the Extensions icon on the Activity Bar on the side of VS Code or by pressing
Ctrl+Shift+X(Windows/Linux) orCmd+Shift+X(macOS). - In the search bar, type
Remote - SSH. - Find the extension published by Microsoft and click the Install button.
You need to add your remote server details to your SSH configuration file, typically located at ~/.ssh/config (Linux/macOS) or %USERPROFILE%\.ssh\config (Windows). This allows you to define aliases and specific connection parameters for your remote hosts.
- Open a terminal (Linux/macOS) or Git Bash (Windows).
- Navigate to your SSH directory:
cd ~/.ssh/If the .ssh directory doesn't exist, create it:
mkdir ~/.ssh
chmod 700 ~/.ssh- Open or create the
configfile using a text editor (e.g.,nano,vim, or VSCode itself):
nano configor
code ~/.ssh/config- Add the following configuration block to the
configfile, replacing the placeholder values with your actual server details:
Host 1.2.3.4
HostName 1.2.3.4
User ubuntu
IdentityFile ~/.ssh/privatekey.pem
StrictHostKeyChecking no
UserKnownHostsFile ~/.ssh/known_hosts
Host 1.2.3.4: This defines an alias for your connection. You can use the IP address directly or choose a more descriptive name (e.g., my-frappe-server).HostName 1.2.3.4: The actual IP address or hostname of your remote server.User ubuntu: The username you use to log in to the remote server.IdentityFile ~/.ssh/privatekey.pem: The path to your private SSH key file. Make sure this file has the correct permissions (chmod 400 ~/.ssh/privatekey.pem).StrictHostKeyChecking no: (Optional, for initial setup convenience, but less secure) This setting prevents SSH from prompting you to confirm the host's authenticity on first connection. It's recommended to set this to yes or ask in production environments after the first successful connection.UserKnownHostsFile ~/.ssh/known_hosts: Specifies the file where known host keys are stored.
- Save and close the config file.
Now you can connect to your remote server directly from VSCode.
- Open the Command Palette in VSCode by pressing
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(macOS). - Type
Remote-SSH: Connect to Host...and select the option. - VSCode will show a list of configured hosts. Select
1.2.3.4(or whateverHostalias you defined). VSCode will open a new window and attempt to establish an SSH connection to your remote server. You might be prompted for your SSH key passphrase if it has one.
Once connected to the remote host, you can open a specific folder on that server.
- With the new VSCode window connected to your remote host, open the Command Palette (
Ctrl+Shift+PorCmd+Shift+P). - Type
Remote-SSH: Open Folder...and select the option. - A file explorer dialog will appear, showing the remote file system. Navigate to the desired folder, e.g.,
/home/ubuntu/frappe_docker. - Click OK.
The VSCode window will reload, and you will now be working directly within the
/home/ubuntu/frappe_dockerfolder on your remote server.
If your remote folder contains a .devcontainer directory with a devcontainer.json file, you can re-open the workspace within a DevContainer. This provides a consistent and isolated development environment.
- Make sure you have the Dev Containers extension installed (similar to Step 1, search for
Dev Containersby Microsoft). - Once your remote folder
/home/ubuntu/frappe_dockeris open in VSCode, open the Command Palette (Ctrl+Shift+PorCmd+Shift+P). - Type
Dev Containers: Reopen in Containerand select the option. VSCode will now build (if necessary) and connect to the DevContainer defined in yourfrappe_dockerproject. This process might take some time for the first build. Once complete, you will have a fully functional development environment within the container, complete with all necessary dependencies and tools.