0% found this document useful (0 votes)
35 views4 pages

MOP Deploying and Managing A GitHub Repository With Docker and Vs Code

The document outlines the process of deploying and managing a GitHub repository using Docker and Visual Studio Code (VS Code). It includes steps for cloning a repository, creating a Dockerfile, building and running a Docker container, integrating with VS Code, and pushing code changes to GitHub. Additionally, it provides validation steps and a rollback plan in case of deployment issues.

Uploaded by

haki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views4 pages

MOP Deploying and Managing A GitHub Repository With Docker and Vs Code

The document outlines the process of deploying and managing a GitHub repository using Docker and Visual Studio Code (VS Code). It includes steps for cloning a repository, creating a Dockerfile, building and running a Docker container, integrating with VS Code, and pushing code changes to GitHub. Additionally, it provides validation steps and a rollback plan in case of deployment issues.

Uploaded by

haki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

MOP Deploying and Managing a GitHub

Repository with Docker and VS Code


Title: Deploying and Managing a GitHub Repository with
Docker and VS Code

1. Objective
To clone a GitHub repository, deploy it using Docker, and integrate the workflow with Visual
Studio Code (VS Code) for efficient development and code management.

2. Prerequisites
 A GitHub repository with your application code.
 Docker installed on the company laptop.
 VS Code installed with necessary extensions.
 Access to the internet to download the repository and Docker dependencies (or cached
dependencies transferred from another machine).

3. Procedure
Step 1: Clone the Repository

1. Open a terminal.
2. Run the following command to clone the repository:

git clone https://github.com/<your-username>/<your-repo>.git

3. Navigate to the cloned repository:

cd <your-repo>

Step 2: Create a Dockerfile

1. Inside the project directory, create a file named Dockerfile:

touch Dockerfile

2. Add the following content to the Dockerfile:


3. # Use the Node.js official image
4. FROM node:latest
5.
6. # Set the working directory inside the container
7. WORKDIR /app
8.
9. # Copy package.json and package-lock.json files to the container
10. COPY package*.json ./
11.
12. # Install dependencies
13. RUN npm install
14.
15. # Copy the rest of the application files
16. COPY . .
17.
18. # Expose the port your app runs on (e.g., 3000)
19. EXPOSE 3000
20.
21. # Command to start your app
CMD ["npm", "start"]

Step 3: Create a .dockerignore File

1. In the project directory, create a .dockerignore file:

touch .dockerignore

2. Add the following content:


3. node_modules
4. npm-debug.log
5. .git
.DS_Store

Step 4: Build the Docker Image

1. Build the Docker image:

docker build -t <your-app-name> .

Step 5: Run the Docker Container

1. Start the container:

docker run -p 3000:3000 <your-app-name>

2. Verify the application is running by visiting:

http://localhost:3000

Step 6: Integrate with VS Code

1. Install VS Code Extensions:


o Open the Extensions view (Ctrl+Shift+X or Cmd+Shift+X on macOS).
o Install the following:
 Docker
GitHub Pull Requests and Issues

GitLens (optional for advanced Git features).

2. Open the Repository in VS Code:
o Navigate to the cloned repository folder and open it in VS Code.
o Use the Source Control tab to manage Git operations (commit, push, pull).
3. Add Docker Support:
o Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).
o Search for and select Docker: Add Docker Files to Workspace.
o Follow the prompts to set up Docker for the project.

Step 7: Push Code Changes to GitHub

1. Make changes to your code in VS Code.


2. Use the Source Control tab to stage and commit changes.
3. Push the changes to GitHub:

git push origin <branch-name>

Step 8: Debug the Application

1. Create a launch.json file for debugging:


o Open the Command Palette and select Run and Debug.
o Configure it for Node.js:
o {
o "version": "0.2.0",
o "configurations": [
o {
o "type": "node",
o "request": "attach",
o "name": "Docker: Attach to Node",
o "port": 9229,
o "address": "localhost",
o "localRoot": "${workspaceFolder}",
o "remoteRoot": "/app"
o }
o ]
}

2. Use breakpoints in your code to debug the application running inside Docker.

4. Validation Steps
 Ensure the application is accessible at http://localhost:<port>.
 Confirm changes can be committed and pushed to GitHub from VS Code.
 Verify Docker images and containers are properly managed via VS Code’s Docker
extension.
5. Rollback Plan
If any issues arise during deployment:

1. Stop the Docker container:

docker stop <container-id>

2. Remove the container and image:


3. docker rm <container-id>
docker rmi <image-id>

4. Revert changes in GitHub if necessary:


5. git reset --hard <commit-hash>
git push --force

6. References
 Docker Documentation
 VS Code Documentation
 GitHub Documentation

End of Document

You might also like