GCP DevOps Project
Sprint 01
Sprint 01
In Sprint-01, you’ll lay the groundwork for your DevOps pipeline by:
Creating and configuring a GitHub repository.
Applying organizational best practices (branching strategy, repository settings).
Writing a sample
Dockerfile
and building the image.Running and testing the Docker image locally.
Pushing the tested code and Docker image to GitHub.
1. GitHub Repository Setup
- Sign in to your GitHub account and click New repository.
- Name the repo according to your organization’s naming convention (e.g.,
project-name
). - Add a
README.md
,.gitignore
, and your preferred branch protection rules. - Clone the repo locally:
git clone [email protected]:your-org/project-name.git cd project-name
2. Apply Organizational Best Practices
- Establish a branching strategy (e.g.,
main
,develop
, feature branches). - Create issue and PR templates under
.github/
. - Configure automated workflows or GitHub Actions as needed.
3. Sample Dockerfile and Image Build
Create a Dockerfile
in the project root:
FROM alpine:3.18
WORKDIR /app
COPY . .
RUN apk add --no-cache python3 py3-pip \
&& pip3 install --no-cache-dir -r requirements.txt
CMD ["python3", "app.py"]
Build the Docker image:
docker build -t your-org/project-sample:latest .
4. Local Testing of Docker Image
Run the container and verify functionality:
docker run --rm -d -p 8080:80 your-org/project-sample:latest
curl http://localhost:8080/health
Task | Command |
---|---|
Build image | docker build -t project-sample:latest . |
Run container | docker run -d -p 8080:80 project-sample:latest |
Health check | curl http://localhost:8080/health |
5. Push to GitHub
- Stage and commit your changes:
git add . git commit -m "Initialize repo and add Dockerfile"
- Push to the remote:
git push origin main
Warning
Avoid committing sensitive information (credentials, tokens) to the repository. Use GitHub Secrets for secure storage.
That wraps up Sprint-01. You’ve now initialized the repository, enforced best practices, built and tested your Docker image, and pushed it to GitHub. Let’s continue to Sprint-02 for CI/CD integration!
Links and References
Watch Video
Watch video content