Welcome to FreeSoftwareServers Confluence Wiki

https://blog.hypriot.com/post/run-your-own-github-like-service-with-docker/

https://github.com/gogs/gogs/tree/main/docker

https://hub.docker.com/r/gogs/gogs

After installation goto:

http://localhost:10880

Choose SQLite for DB

I adjust domain to be sub.domain.com and application URL to be https://sub.domain.com (no port) as I use a reverse proxy secured via SSL

Add Keys via UI for SSH

Test SSH Access via CLI:

ssh git@sub.domain.com -p 10022

Clone Repo:

git clone ssh://git@sub.domain.com:100222/username/reponame.git

Adjust username:

git config --global --edit
 git commit --amend --reset-author

Make Changes and Push

git add .
git commit
git push
WD=/opt/git
mkdir -p $WD/{setup,data,hooks}
cd $WD/setup
cat << 'EOF' >docker-compose.yaml
version: '3.7'

services:
 git:
    container_name: git
    image: gogs/gogs:latest
    hostname: git
    ports:
      - '10022:22'
      - '10880:3000'
    volumes:
      - type: bind
        source: /opt/git/data/
        target: /data      
    environment:
      - 'TZ=${TZ}'

EOF
chmod +x docker-compose.yaml
cd $WD/setup
cat << 'EOF'>.env
TZ=America/Whitehorse
EOF
chmod +x .env
WD=/opt/git/setup
cat << EOF >$WD/git.service.setup.sh
cat << EOL >/lib/systemd/system/git.service
[Unit]
Description=git_Docker
Requires=docker.service network-online.target

[Service]  

WorkingDirectory=$WD
ExecStartPre=docker-compose pull
Restart=on-abnormal
ExecStart=/usr/bin/docker-compose --project-name git --project-directory $WD -f $WD/docker-compose.yaml up --force-recreate
ExecStop=/usr/bin/docker-compose --project-name git --project-directory $WD -f $WD/docker-compose.yaml stop

[Install]
WantedBy=multi-user.target
EOL
systemctl enable git
systemctl restart git
systemctl status git
EOF
chmod +x $WD/git.service.setup.sh
$WD/git.service.setup.sh
echo 'alias gitcli="docker exec -it git /bin/bash"' >> ~/.bashrc
source ~/.bashrc
/usr/bin/docker-compose --project-name git --project-directory /opt/git/setup -f /opt/git/setup/docker-compose.yaml up --force-recreate
  • No labels