Skip to content

workshop-msano/sampleTodo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Overview

Install git inside a container and establish remote connection using VSCode. Incorporating Docker containers into actual development has become easier for development and version control purposes. I have shared the knowledge gained from creating this application in a Qiita post.

Demo

Tools Used

In my environment, I have installed Docker on Ubuntu. It is assumed that you can connect to GitHub via SSH using VSCode.

__β€» I received a report from someone who helped with the verification process that Rootless Mode is required to use Docker with VSCode. __ I will update with additional information if available.

Tool Version Remarks
Docker 20.10.21
docker-compose 1.29.2
Dev Containers 0.266.1 VSCode extension

Folder Structure

root/
  β”œ .devcontainer/
  β”‚  β”” devcontainer.json
  β”œ templates/
  β”‚  β”” index.html
  β”œ .dockerignore
  β”œ Dockerfileγ€€
  β”œ docker-compose.yml
  β”œ .gitignore
  β”œ app.py
  β”” requirements.txt

Flow from Cloning the Template to Setting Up the Development Environment

β€» The installation of each tool has been completed.

  1. Clone the SampleTodo repository from this repository.

    git clone git@github.com:workshop-msano/sampleTodo.git
    
  2. Open the files in VSCode. Press the Remote Container start button at the bottom left of VSCode.


2022-12-10-104132


  1. Select Open Folder in Container from the popup window in VSCode.

2022-12-10-104902




  1. Click Open in the popup window.

2022-12-10-105428


  1. After a while, VSCode will be displayed. If Dev Container is displayed next to the Remote Development button at the bottom left, it means it was successful!
    γ€€

2022-12-10-105935


  1. You can access the web app from http://localhost:8000.


<p>2022-12-10-214935" border="0" width=400>
<br></p>
<ol start=

  • Since git is already installed in the container, configure it to access GitHub from the container. Open the terminal and run the following commands.
    It is assumed that you can connect to GitHub via SSH using VSCode.

    git config --global user.email '<your setting>'
    git config --global user.name '<Your setting>'
    
    mkdir -p ~/.ssh/
    curl -s -o ~/.ssh/id_ed25519 "https://github.com/$(git config --global --get user.name).keys"
    
  • Next, enter ssh -v git@github.com in the terminal.
    If there is a successful access to GitHub displayed in the log, it is complete! You can create a repository on GitHub and manage the source code version from within the Docker container.



  • Bonus

    Let's use a shell script to access the database in the Docker container. Execute the following commands outside the container.

    docker exec -it sampletodo_db /bin/sh
    
    psql --username postgres
    

    Well done! πŸŽ‰πŸŽ‰πŸŽ‰

    About

    A template for novice Docker developers showing how Docker can be applied to development.🐳

    Topics

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published