Skip to content
This repository was archived by the owner on Apr 11, 2020. It is now read-only.

jules2689/docker-compose-vscode

Repository files navigation

Docker-Compose + VSCode Remote Development

This application is pretty much a default Rails app. It has a single scaffold to show it works with a database, otherwise the intention is that it runs in Docker Compose and is setup for VSCode.

How to Run?

1) Setup VS Code

Open up folder in VSCode (currently need insiders edition!) with your project

a) Make sure you have the Remote Development plugin installed (https://code.visualstudio.com/blogs/2019/05/02/remote-development#_get-started) b) Make sure you have the Docker plugin (https://marketplace.visualstudio.com/items?itemName=PeterJausovec.vscode-docker)

2) Start Docker Compose

i) Run docker-compose -f .devcontainer/docker-compose.yml build ii) Run docker-compose -f .devcontainer/docker-compose.yml up

3) Start up the connection

VSCode can automatically handle things if the folder you open has a devcontainer.json or .devcontainer/devcontainer.json. It can handle docker-compose too, which is setup in this demo.

Open up the folder, then open the Docker extension. Right click on the web container, and click "Attach Visual Studio Code".

image

4) Use the terminal integrated in vscode like it was a locally running thing

This might take 20-30 seconds to boot.

VSCode and Docker Compose Running

Protip

Add this snippet to your ~/.bash_profile (or zsh, etc) to automatically enable a COMPOSE_FILE variable, so you don't need to specify the -f ... option on the docker-compose commands.

docker_compose() {
  if [[ -f ".devcontainer/docker-compose.yml" ]] && [[ ! -f "docker-compose.yml" ]]; then
    export COMPOSE_FILE=".devcontainer/docker-compose.yml"
  else
    unset COMPOSE_FILE
  fi
}
trap 'docker_compose' DEBUG

About

Runs a (basically) default Rails app in Docker Compose/VSCode Remote Development

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published