Environment construction with VSCode + Remote Container (Go / Application)

Preface and Acknowledgments

The other day, I made a remote container using a simple method in Go language (Reference: Environment construction with VSCode + Remote Container (go edition)), but after making it, LGTM from the master of the mind (@MegaBlackLabel) Along with the following ~~ Tsukkomi ~~ Revelation.

A few days later, the government reached the point of making an app in earnest, and it became clear that the environment ahead was not enough, so I faced this issue again and created an environment like that, so I will summarize it again. ..

table of contents

-1. Prerequisite environment -2. Create Working Folder -3. Create file for container -4. Create container configuration file for remote -5. Start Container

1. Prerequisite environment

Other than this, basically no preparation is required. If you don't know how to install Remote --containers, refer to the above (VSCode + Remote Container environment construction (go)).

We have confirmed the operation on Windows 10 (Pro), but there is probably no problem with other OS including home (WSL2 is required separately for home).

2. Create working folder

This time, the configuration is roughly as follows (except for ".devcontainer", the folder name is arbitrary).

go-proj
├─ .devcontainer
│    └─ devcontainer.json
├─ docker
│    └─ go
│        └─ Dockerfile
├─ src
└─ docker-compose.yml

Create under the top directory. Each file will be described in the following items.

3. Create a file for the container

If you change the folder structure, change it accordingly.

docker-compose.yml

(If you make it according to this article, under the top directory "go-proj")

docker-compose.yml


version: '3.8'

services:
  app:
    build: ./docker/go/
    command: /bin/sh -c "while sleep 1000; do :; done"
    ports:
      - 8080:8080
    volumes:
      - ./src:/go/src:cached

Dockerfile

(If you make it according to this article, under "go-proj/docker/go")

Dockerfile


#Latest at the time of writing this article
FROM golang:1.15

WORKDIR /go/src

ENV GO111MODULE=on
ENV GOPATH /go

RUN go get -v \
        golang.org/x/tools/gopls \
        github.com/ramya-rao-a/go-outline \
        github.com/sqs/goreturns

4. Create a remote container configuration file

devcontainer.json

(If you make it according to this article, under "go-proj/.devcontainer")

devcontainer.json


{
    "name": "go",

    "dockerComposeFile": [
        "../docker-compose.yml"
    ],

    "service": "app",
    "workspaceFolder": "/go/src",

    "settings": { 
        "terminal.integrated.shell.linux": null,
        "go.gopath": "/go"
    },

    "extensions": [
		"golang.go",
    ],

    "shutdownAction": "stopCompose"
}

5. Start the container

Open the project folder with VSCode and execute Remote-Containers: Reopen in Container from the command palette and others.

X. Reference article

Building a development environment with Go + echo + Docker + VSCode + Remote Containers (supports hot reload and step execution): Referenced halfway (Progress according to this procedure is currently used in the maintenance of realize) Not possible). As an aside, the author builds with realize → air (and echo → gin).

Recommended Posts

Environment construction with VSCode + Remote Container (Go / Application)
Web application created with Python + Flask (using VScode) # 1-Virtual environment construction-
Comfortable Jupyter Lab (Python) analysis environment created with Docker + VSCode + Remote Container
Go language environment construction
Web application made with Python3.4 + Django (Part.1 Environment construction)
Pepper-kun remote control environment construction with Docker + IPython Notebook
QGIS3 Python plugin development environment construction with VSCode (macOS)
Ssh to virtual environment with remote development of vscode
Operate Db2 container with Go
ML environment construction with Miniconda
Environment construction, Build -Go edition-
Build a Go development environment with VS Code's Remote Containers
Build a comfortable development environment with VSCode x Remote Development x Pipenv
Get started with Python! ~ ① Environment construction ~
ruby environment construction with aws EC2
Easy Jupyter environment construction with Cloud9
Automate environment construction with Shell Script
Python3 environment construction with pyenv-virtualenv (CentOS 7.3)
Using Chainer with CentOS7 [Environment construction]
pytorch @ python3.8 environment construction with pipenv
Data science environment construction with Docker
Environment construction with pyenv and pyenv-virtualenv
Create a Python execution environment for Windows with VScode + Remote WSL
[Ubuntu 18.04] Python environment construction with pyenv + pipenv
Vue.js + Flask environment construction memorandum ~ with Anaconda3 ~
WEB application development using django-Development environment construction-
Where VSCode + venv environment construction got stuck
Python3 + venv + VSCode + macOS development environment construction
VScode environment construction (Windows10, Python, C ++, C, Git)
A memo packed with RADEX environment construction
Let's get along with Python # 0 (Environment construction)
Try creating a web application with Vue.js and Django (Mac)-(1) Environment construction, application creation
Collecting information from Twitter with Python (Environment construction)
Build a C language development environment with a container
Hello World with gRPC / go in Docker environment
Analytical environment construction with Docker (jupyter notebook + PostgreSQL)
MacOS 10.11 environment construction: Powerline with Anaconda and Dein.vim
Python environment construction (Anaconda + VSCode) @ Windows10 [January 2020 version]
Go (Echo) Go Modules × Build development environment with Docker
[0] TensorFlow-GPU environment construction built with Anaconda on Ubuntu
Poetry-virtualenv environment construction with python of centos-sclo-rh ~ Notes
First python ① Environment construction with pythonbrew & Hello World !!
From Python environment construction to virtual environment construction with anaconda
Build a Python machine learning environment with a container
DeepIE3D environment construction
Emacs-based environment construction
Linux environment construction
Python environment construction
Python with Go
Environment construction (python)
django environment construction
CodeIgniter environment construction
python environment construction
Python --Environment construction
Python environment construction
Golang environment construction
python environment construction
Word2vec environment construction
Virtual environment construction with Docker + Flask (Python) + Jupyter notebook
[Python] OpenCV environment construction with Docker (cv2.imshow () also works)
From Kafka to KSQL --Easy environment construction with docker