README
¶
Gin Example Project Deployment Guide on Leapcell
Introduction
This is an example project built with the Gin web framework. The main objective of this project is to teach users how to deploy a Gin application on the Leapcell platform. Whenever you make changes to the Markdown files in the content directory and perform a git merge into the main branch, an automatic deployment will be triggered on Leapcell.
Project Structure
.
├── LICENSE # License file for the project
├── content # Directory containing Markdown files for blog posts
│ ├── first-review.md # First sample blog post in Markdown
│ └── second.md # Second sample blog post in Markdown
├── go.mod # Go module file, specifying project dependencies
├── go.sum # Go sum file, recording the expected cryptographic checksums of dependencies
├── main.go # The main entry point of the Gin application
├── static # Directory for static files
│ └── images # Sub - directory for image files
│ └── logo.png # Example logo image
└── templates # Directory for HTML templates
├── index.tmpl # Template for the home page
└── single.tmpl # Template for a single blog post
Prerequisites
- A GitHub (or other Git - based) repository for your project.
- A Leapcell account. You can sign up at Leapcell's official website.
- Basic knowledge of Git commands and Go programming.
- Go programming environment installed on your local machine.
Local Setup
- Clone the Repository
git clone https://github.com/leapcell/gin-blog cd gin-blog - Install Dependencies
go mod tidy - Run the Application Locally
Then, open your browser and visitgo run main.gohttp://localhost:8080to see the application running.
Deployment on Leapcell
- Connect Your Repository to Leapcell
- Log in to your Leapcell account.
- Navigate to the project creation page and select the option to connect your Git repository (e.g., GitHub).
- Authorize Leapcell to access your repository and choose the
mainbranch.
- Configure the Deployment
- Build Command: In Leapcell, set the build command to
go build -o main main.go. This will compile your Go application. - Start Command: Set the start command to
./main. This will start your compiled application.
- Build Command: In Leapcell, set the build command to
- Initial Deployment
- After configuration, Leapcell will automatically start the first deployment. You can monitor the deployment progress on the Leapcell dashboard.
Try Making Changes and Merging to the Main Branch
- Modify a Blog Post
- Open one of the Markdown files in the
contentdirectory, such asfirst - review.md. - Make some changes to the content, for example, add a new paragraph or correct a typo.
- Open one of the Markdown files in the
- Stage and Commit Your Changes
git add content/first - review.md git commit -m "Update the content of first - review.md" - Create a New Branch (Optional but Recommended)
git checkout -b new - content - branch - Merge Your Changes to the Main Branch
- First, switch back to the
mainbranch:git checkout main - Then, pull the latest changes from the remote
mainbranch:git pull origin main - Finally, merge your changes from the new branch (if you created one):
git merge new - content - branch - Push the updated
mainbranch to the remote repository:git push origin main
- First, switch back to the
- Watch the Automatic Deployment
- Once you push the changes to the
mainbranch, Leapcell will detect the changes and start an automatic deployment. - Check the Leapcell dashboard to see the deployment progress. After the deployment is successful, you can visit your application's URL on Leapcell to see the updated content.
- Once you push the changes to the
Troubleshooting
- If the deployment fails, check the deployment logs on Leapcell. They usually provide detailed error messages.
- Ensure that all the dependencies in the
go.modfile are correctly specified and compatible with each other.
Conclusion
By following this guide, you should be able to deploy your Gin application on Leapcell and experience the automatic deployment feature when you update your content. Try making more changes to your blog posts and enjoy the seamless deployment process!
Documentation
¶
There is no documentation for this package.
Click to show internal directories.
Click to hide internal directories.