首页 > 轻量级git服务器 Gogs git 服务器搭建

轻量级git服务器 Gogs git 服务器搭建

gogs搭建教程:

原文链接:

https://garthwaite.org/docker-gogs.html

内容:

Dockerized Gogs git server and alpine postgres in 20 minutes or less

// under docker

I’ve babysat gitlab omnibus before and it wasn’t any fun. So when a group of volunteer developers decide to rewrite a community website “with devops” I did what is becoming an annual exercise looking for a free many-user private git repo.

Unsatisfied with bitbucket and friends I decided to try docker + gogs.

$ docker pull gogs/gogs

$ docker images gogs/gogs

REPOSITORY TAG IMAGE ID CREATED SIZE

gogs/gogs latest 40ce39eb7c4b 2 weeks ago 81.17 MB

The image is about 81MB and based on Alpine Linux which is perfect, it saves me from forking the repo and doing that myself.

$ docker run --rm --name gogs gogs/gogs

Apr 8 00:03:03 syslogd started: BusyBox v1.24.1

2016/04/08 00:03:03 [W] Custom config ‘/data/gogs/conf/app.ini’ not found, ignore this if you’re running first time

2016/04/08 00:03:03 [T] Custom path: /data/gogs

2016/04/08 00:03:03 [T] Log path: /app/gogs/log

2016/04/08 00:03:03 [I] Gogs: Go Git Service 0.9.15.0323

2016/04/08 00:03:03 [I] Log Mode: Console(Trace)

2016/04/08 00:03:03 [I] Cache Service Enabled

2016/04/08 00:03:03 [I] Session Service Enabled

2016/04/08 00:03:03 [I] SQLite3 Supported

2016/04/08 00:03:03 [I] Run Mode: Development

2016/04/08 00:03:03 [I] Listen: http://0.0.0.0:3000

Apr 8 00:03:03 sshd[31]: Server listening on 0.0.0.0 port 22.

Note that this docker image listens on two ports: gogs on 3000 and ssh on 22. Usually running ssh in a container is considered bad form but in this case we are supporting git-over-ssh. Let’s kill this container and restart it properly.

$ docker stop gogs; docker rm gogs
$ mkdir -p /srv/lxc/gogs/data
$ docker run -d --name gogs -p 8300:3000 -p 8322:22 -v /srv/lxc/gogs/data:/data gogs/gogs

Let’s take a look at that web service: open http://vault:8300 gogs start page

Things are going so well at this point that I feel emboldened - what is it like running postgres in docker nowadays?

$ docker pull postgres

… starts downloading two hundred something MB …



200MB for just a database manager? Not in my digital backyard. A search for docker alpine postgresturns up kiasaki/alpine-postgres in not one but practically all of the results.

$ docker pull kiasaki/alpine-postgress
$ docker images kiasaki/alpine-postgres

REPOSITORY TAG IMAGE ID CREATED SIZE

kiasaki/alpine-postgres latest b58856735da8 5 weeks ago 22.69 MB

The docker hub page for kiasaki/alpine-postgres shows how to start the image:

$ mkdir -p /srv/lxc/postgres/data
$ docker run -d --name postgres -e POSTGRES_PASSWORD=supersecret -v /srv/lxc/postgres/data:/var/lib/postgresql/data -p 5432:5432 kiasaki/alpine-postgres$ docker ps -s | grep postgres

b33cf374af70 kiasaki/alpine-postgres “/docker-entrypoint.s” 7 minutes ago

Up 7 minutes 0.0.0.0:5432->5432/tcp postgres 48 B (virtual 22.69 MB)

22 MB < 200 MB and stack-smashing protection for postgres to boot.

At this point we could spin up the gogs container and use the postgres superuser but lets see how we go about administrating postgres without installing psql.

$ docker exec -it postgres psql -U postgres

psql (9.4.6, server 9.5.1)
WARNING: psql major version 9.4, server major version 9.5.Some psql features might not work.
Type "help" for help.postgres=# CREATE USER gogs WITH PASSWORD '^go4git&docker';
CREATE ROLE
postgres=# CREATE DATABASE gogs OWNER gogs;
CREATE DATABASE
postgres=# q
Great now we spin up gogs this time linking it to postgres and data volumes:

$ docker stop gogs; docker rm gogs

$ docker run --link postgres -d --name gogs

-p 8300:3000 -p 8322:22 -v /srv/lxc/gogs/data:/data gogs/gogs

$ open https://vault:8300

Back at the start page select [[postgres]] with user:gogs pass:^go4git&docker I found a hiccup here - after filling in the credentials it created the DB but forwarded my client to localhost:3000 and not vault:8300 (in my case).From here I made an account dang and it was nice enough to pull in my gravatar. I made an empty repo called 'blog' then added http://vault:8300/dang/blog.git as a remote to my existing repo:

$ git remote add gogs http://dang@vault:8300/dang/blog.git

$ git push gogs master

Password for 'http://dang@vault:8300':
Voila! I can make and push branches then turn those into pull requests in gogs. Remember you can peak at the logs of either container:

$ docker logs -f gogs

$ docker logs -f postgres

Suggestions on how better to explore and learn docker are always welcome in the comments.Credits: Thanks to Manuel Carlos Rodriguez for some corrections.

更多相关:

  •   一、准备工作 1.、工具:win10,idea2018,maven3.5,jdk8 二、win10安装docker 1、win10安装docker:http://www.runoob.com/docker/windows-docker-install.html 2、安装完毕后,点击小鲸鱼,选择settings   点击Daemo...

  • 1、启动docker: Docker Quickstart Terminal (快捷键)启动docker   2、SECURECRT工具链接docker:     转载于:https://www.cnblogs.com/aibaiyang/p/9007074.html...

  • 杀死所有正在运行的容器 复制代码代码如下: docker kill $(docker ps -a -q)    删除所有已经停止的容器 复制代码代码如下: docker rm $(docker ps -a -q)    删除所有未打 dangling 标签的镜像 复制代码代码如下: docker rmi $(docker image...

  • 为什么80%的码农都做不了架构师?>>>    1. 修改已有镜像 先使用下载的镜像启动容器。 $ sudo docker run -t -i training/sinatra /bin/bash root@0b2616b0e5a8:/# 在容器中添加 json 和 gem 两个应用。 root@0b2616b0e...