├── Dockerfile ├── LICENSE ├── README.md └── nginx.conf /Dockerfile: -------------------------------------------------------------------------------- 1 | # small is beautiful 2 | FROM alpine:latest 3 | 4 | MAINTAINER Anthony Hogg anthony@hogg.fr 5 | 6 | # The container listens on port 80, map as needed 7 | EXPOSE 80 8 | 9 | # This is where the repositories will be stored, and 10 | # should be mounted from the host (or a volume container) 11 | VOLUME ["/git"] 12 | 13 | # We need the following: 14 | # - git-daemon, because that gets us the git-http-backend CGI script 15 | # - fcgiwrap, because that is how nginx does CGI 16 | # - spawn-fcgi, to launch fcgiwrap and to create the unix socket 17 | # - nginx, because it is our frontend 18 | RUN apk add --update nginx && \ 19 | apk add --update git-daemon && \ 20 | apk add --update fcgiwrap && \ 21 | apk add --update spawn-fcgi && \ 22 | rm -rf /var/cache/apk/* 23 | 24 | COPY nginx.conf /etc/nginx/nginx.conf 25 | 26 | # launch fcgiwrap via spawn-fcgi; launch nginx in the foreground 27 | # so the container doesn't die on us; supposedly we should be 28 | # using supervisord or something like that instead, but this 29 | # will do 30 | CMD spawn-fcgi -s /run/fcgi.sock /usr/bin/fcgiwrap && \ 31 | nginx -g "daemon off;" 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Anthony Hogg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | A dead simple git smart-http server using nginx as a frontend. No authentication, no SSL, push is free-for-all. 2 | 3 | > _caveat emptor_ this is not intended for production use 4 | 5 | Usage: 6 | 7 | ``` 8 | docker run -d -p 4080:80 -v /path/to/host/gitdir:/git ynohat/git-http-backend 9 | ``` 10 | 11 | Unauthenticated push will not work unless you enable it in repositories: 12 | 13 | ``` 14 | cd /path/to/host/gitdir 15 | git init --bare test.git 16 | cd test.git 17 | git config http.receivepack true 18 | ``` 19 | 20 | Repos will then be accessible at `http://localhost:4080/git/.git`. 21 | -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | worker_processes 1; 2 | 3 | error_log /var/log/nginx/error.log; 4 | pid /run/nginx.pid; 5 | user root; 6 | 7 | events { 8 | worker_connections 1024; 9 | } 10 | 11 | http { 12 | server { 13 | listen *:80; 14 | 15 | root /www/empty/; 16 | index index.html; 17 | 18 | server_name $hostname; 19 | access_log /var/log/nginx/access.log; 20 | 21 | #error_page 404 /404.html; 22 | 23 | #auth_basic "Restricted"; 24 | #auth_basic_user_file /www/htpasswd; 25 | 26 | location ~ /git(/.*) { 27 | # Set chunks to unlimited, as the bodies can be huge 28 | client_max_body_size 0; 29 | 30 | fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend; 31 | include fastcgi_params; 32 | fastcgi_param GIT_HTTP_EXPORT_ALL ""; 33 | fastcgi_param GIT_PROJECT_ROOT /git; 34 | fastcgi_param PATH_INFO $1; 35 | 36 | # Forward REMOTE_USER as we want to know when we are authenticated 37 | fastcgi_param REMOTE_USER $remote_user; 38 | fastcgi_pass unix:/run/fcgi.sock; 39 | } 40 | } 41 | } 42 | --------------------------------------------------------------------------------