Recently, I launched a personal open source project in GitHub – “golden”, a super lightweight fortress machine (springboard machine) service developed in go language, so I want to write a blog to record my open source experience.
Although it’s not the first time to write an open source project, we can’t let go of the enthusiasm of this blog post. We don’t know when to write next time.
And the main purpose of this article is to share some open source experience for readers.
Generate Idea A kind of
First of all, whether it’s a personal project or an open source project, there must be an idea. Let me talk about it first
gortalHow does the idea of this project come from.
I have a group of friends who love open source technology, tnk-studio-
technical studioSmall technical workshop.
@Mayneyao students’ open source project Chinese independent blog research needs servers to run crawlers, so we will contribute the idle cloud computing resources at hand.
I thought that maybe there would be such a demand in the future, so I thought of the jumpserver bastion machine used by the company, and I wanted to set up one of the servers in the organization.
dockerA shuttle, two or three runs up.
As a result, the server is stuck
jumpserverI took a look at the official documents.
Jumpserver environment requirements:
Hardware configuration: 2 CPU cores, 4G memory, 50g hard disk (minimum)
Our idle cloud computing resources are basically
1 core 2 GIt’s a configuration that can’t be played.
Then I searched whether there were any other projects of the same type and lighter weight that could be used. Finally, I didn’t find the right one.
Make it by yourself A kind of
If not, make it by yourself!
IdeaWith it, it’s bad for programmers. Now there’s no shortage of programmers. It’s bad for languages. It must be the best language in the world
At first, I wanted to think about using my own native language
Python, but later considered
GoLanguage is simpler to deploy, and whether it’s a generated executable or
dockerThe images are very small, so I decided to choose
So what should I do? Because I’ve experienced it
jumpserverSo I want to develop it in the same way. Of course, for the sake of light weight, it must have been abandoned
Web, fully using the terminal to interact.
The next step is to choose the open source wheel. Of course, when implementing your idea, you should never do it from scratch. If you have excellent open source solutions, you must use them. If you don’t meet your own needs, you need to modify them. When using one of the open-source projects, manoldco / prompt UI, you will find that it does not meet the needs. At this time, you can fork a copy to your own warehouse and use it yourself.
Finally, the wheels selected according to the technical scheme are as follows:
Terminal interaction – Manifold Co / prompt UI
Sshd service development – gliderlabs / SSH
SSH relay client – helloyi / go SSH client
Other personal open source projects – Fatih / color, op / go logging, etc
Project to do A kind of
Everything has been chosen, ready to start, but found where I should start?
You need to make a list
To-doYes, I use the note taking tool of note. Use Kanban to list the functions to be implemented in the project, and drag them into the finished item after implementation.
In this way, not only can I sort out what I need to do at present, but also it is very helpful for collaborative development of multiple people.
When you are ready to do, you can officially start work. When the function is almost completed, it is the official start time.
Add CI ⚙
Basic functions are ready for release
GoThe developed program only needs to be packaged into binary executable files of different platforms.
But so many platforms, one by one
buildThen upload, which is what programmers do? This is
CI-What continuous integration (CI) does.
Before developing this project, I used
Travis CIIt’s right.
GithubOpen source projects are free. But a while ago
Github ActionsSo I chose it with a taste attitude.
It is also very simple to use. Click the
ActionsThe menu can enter the warehouse
I feel that
Travis CIBy contrast, its biggest advantage is its
MarketplaceThere are many open source works written by others
ActionsIt can be used directly after simple modification, and these
ActionsOf course, it is also used
How to use it will not be described in detail here. For those who are interested, please refer to the official document of GitHub actions.
Here I add a “create release” to the warehouse to automatically package all images
actions, its warehouse address I also put here ngs / go-release.action.
The final effect is to automatically package binary executables for all platforms, and compress and upload them to
A docker image A kind of
Of course, one service is not enough
DockerImage, not yet understood
DockerYou can take a look at Ruan Yifeng’s introduction to docker. I think
DockerIt’s one of the greatest inventions of programmers in the 21st century.
GithubIt can’t be used in combination.
No need to write extra
Github ActionsConfiguration or other
CIConfiguration file, you only need to connect your warehouse with
Docker HubOf course, don’t forget to put it in your warehouse
Docker HubWhen the warehouse is configured with the logic to automatically build the image, it is finished.
Docker HubThe configuration guidelines for are also very good and easy to understand.
Of course, it’s very, very important here if you’re using
GoLanguage development projects,
DockerImage construction must be divided into two steps. One is compiling image and the other is formal image. In this way, the final packaged image will only contain one binary file, rather than package the source code together.
FROM golang:1.12-alpine AS builder #... omit code FROM alpine:latest LABEL maintainer="Elf Gzp (https://elfgzp.cn)" COPY --from=builder /opt/gortal ./ RUN chmod +x /gortal #... omit code
The project is complete
DockerfileThe links are as follows. You can view the complete
It can be seen from the picture that there are two steps to build and one step to build the final packaged
DockerThe image size difference is very large.
Let readme look higher
Next is the most important step. Write it
Readme, it’s the cover of your project. Most of the time, I’m browsing other people’s open-source projects. I may not care what he has done in this project, but from his
ReadmeIt’s very good. I’ll give it to him
And it’s better to be bilingual
ReadmeIn this way, foreigners can understand it. If they can’t write a Chinese version, the rest will be handed over to Google translator.
ReadmeIt’s better not to be all words. It’s better to have a demonstration
GIF, so that those who come in will know what your project is for the first time.
Here I recommend the tool of licecap, which is used to record all the moving pictures in this film.
ReadmeWhen it’s done, add it
Badges-Badge is the finishing touch of dragon painting.
BadgesWe just need to use this open source project shields, select the badge we want, fill in the URL, copy and paste it to
ReadmeLet’s fix it.
After copying and pasting, you will get one
shieldsYou only need to change the link to
MarkdownThe image link format is OK, refer to the link.
Begging Star A kind of A kind of
After the project is completed, of course, you can’t leave it alone. Unless your project is very, very good, he won’t grow stars by himself.
Taking this project as an example, the author went to V2EX to share his own project, and gained many stars A kind of It is.
You need to go to various communities to share your open source projects, such as V2EX, rare earth nuggets, segment fault and so on.
Let more people see your project. The same is true for blogging. If you don’t share it, there will be no positive feedback, and there will be less motivation.
To summarize A kind of
In this article, I don’t introduce the development process of the project too much, because I think the process other than development is more worthy of sharing.
Open source projects are not just implemented
IdeaIt’s over. You may need to make it easier to maintain and do some repetitive things automatically. You have to pack it and share it so that more people can use it. When there are more people, the project takes time to iterate and maintain.
At the end of the article, I think the article is pretty good. I think this open source project is OK. Enjoy it
starA kind of Come on, https://github.com/tnk-studio/royal.