Build debug environment on container --Build local development environment for Rails tutorial with Docker-

Introduction

We are building a local development environment with Docker and rerunning the Rails tutorial.

--Rails 6 compatible with the latest version of Rails tutorial (as of 2020.8.6) --Development environment can be reproduced using Docker --Do not install in the local environment as much as possible

This time, the part corresponding to Chapter 7 of the Rails tutorial, I will introduce the contents to debug when developing on the Docker container

The first Building a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack) --Qiita

Second time Building a local development environment for Rails tutorials with Docker --Introducing RSpec & Deploying Heroku with CircleCI --- Qiita

3rd Building a local development environment for Rails tutorials with Docker --Introducing Bootstrap and Font Awesome with Webpack --- Qiita

Personally developed app mdClip

When operating on the Docker container, use the terminal command as appropriate.

$ docker-compose run app ...

Or

$ docker-compose exec app ...

Please replace with.

Debug Rails in the development environment on the Docker container

Method 1 Attach to Rails container-> Detach

Reference site Enable debugging in Docker and Rails 5.2 development environment-Coconala Yomoyama Blog

Attach to Rails container

$ docker attach $(docker-compose ps -q app)

You can now use the debug console

Detach from container

If you exit debug with quit Since the container will be terminated, rails server will also drop If you think this is very inconvenient

If you just detach from the container (Control P-> Control Q), you don't have to close the container.

However, when operating with the VS Code console Control P, Control Q cannot be assigned to other shortcuts

This is a solution by replacing the touch keys with a container

Reference article How to solve Ctrl-p double press problem (detach-keys problem) with docker-Qiita

Write the settings in ~ / .docker / config.json

vi ~/.docker/config.json
{
  # ...abridgement
  "detachKeys": "ctrl-e"
}

I set it to be detachable with control + e

Method 2 Run a debugging container with VS Code

From the debug function of VS code, there seems to be a way to set up a container for debugging and debug.

Developing inside a Container using Visual Studio Code Remote Development

I thought it would be seamless and convenient I've spent a little time so far, so I'll add it on another occasion.

Personal notes

Get started with development Containers in Visual Studio Code

VS Code --Connect to a Rails app running on Docker Compose with Remote Containers-Coffee simmered

Troubleshoot

Both are due to different versions of Bootstrap I don't think it makes sense to spend too much time researching it.

You may want to match the Bootstrap version

Form moves to the left

#Before correction
col-md-offset-3
#Revised
offset-md-3

There is no $ state-danger-text

$text-danger: #dc3545;

# ...Omission...

.field_with_errors {
  @extend .has-error;
  .form-control {
    color: $text-danger;
  }
}

There is no .has-error

.has-error -> :invalid

$text-danger: #dc3545;

# ...Omission...

.field_with_errors {
  @extend :invalid;
  .form-control {
    color: $text-danger;
  }
}

Recommended Posts

Build debug environment on container --Build local development environment for Rails tutorial with Docker-
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
Build a development environment for Docker + Rails6 + Postgresql
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Build Couchbase local environment with Docker
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
Build Unity development environment on docker
How to build Rails, Postgres, ElasticSearch development environment with Docker
Build a local development environment for Open Distro for Elasticsearch with multiple nodes using Docker
Build a PureScript development environment with Docker
Build a Wordpress development environment with Docker
Build an environment with Docker on AWS
Build an Ultra96v2 development environment on Docker 1
How to build Rails 6 environment with Docker
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
Build a development environment for Django + MySQL + nginx with Docker Compose
Steps to build a Ruby on Rails development environment with Vagrant
Build a local development environment for Rails tutorials with Docker-Introduce Bootstrap and Font Awesome with Webpack-
How to build a Ruby on Rails environment using Docker (for Docker beginners)
Build a WordPress development environment quickly with Docker
Build a development environment for Docker, java, vscode
[Rails] How to build an environment with Docker
[First team development ②] Build an environment with Docker
Wordpress local environment construction & development procedure with Docker
Build a development environment to create Ruby on Jets + React apps with Docker
Build Java development environment with VS Code on Mac
Build a Ruby on Rails development environment on AWS Cloud9
How to build docker environment with Gradle for intelliJ
Docker the development environment of Ruby on Rails project
Stable development environment construction manual for "Rails6" with "Docker-compose"
Build Java development environment with WSL2 Docker VS Code
Build Rails (API) x MySQL x Nuxt.js environment with Docker
Build WordPress environment with Docker (Local) and AWS (Production)
Debug the VSCode + Docker + PHP development environment with XDebug.
[Docker] Rails 5.2 environment construction with docker
Build docker environment with WSL
Build DynamoDB local with Docker
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
Definitely useful! Debug code for development in Ruby on Rails
I made a development environment with rails6 + docker + postgreSQL + Materialize.
[Procedure 1 for beginners] Ruby on Rails: Construction of development environment
Rails application development environment construction with Docker [Docker, Rails, Puma, Nginx, MySQL]
Rails + MySQL environment construction with Docker
Build a Node.js environment with Docker
Environment construction with Docker for beginners
Build PlantUML environment with VSCode + Docker
Build Java development environment (for Mac)
Rails on Docker environment construction procedure
Build jooby development environment with Eclipse
[Environment construction with Docker] Rails 6 & MySQL 8
Build docker + laravel environment with laradock
Build WebRTC Janus with Docker container
Build Go development environment with WSL2 + Docker Desktop + VSCode (Remote --Containers)
[App development 0.5] [Node.js express Docker] Build an environment for Node.js Express MongoDB using Docker
How to install Pry after building Rails development environment with Docker