Skip to content

Latest commit

 

History

History
111 lines (85 loc) · 2.92 KB

README.md

File metadata and controls

111 lines (85 loc) · 2.92 KB

gitfab2 Build Status Code Climate Coverage Status

Setup a build environment

Requirements

  • Docker 17 ce or later
  • Docker Compose 1.16 or later

Installation

$ git clone git@github.com:webdino/gitfab2.git
$ cd gitfab2
$ cp .env.sample .env
$ docker-compose build

Open in Dev Container

  1. Open in your VSCode
  2. Open "Command Palette" (Ctrl + Shift + P)
  3. Select "Dev Containers: Reopen in Container"

Start Docker Compose

$ docker-compose up
$ docker-compose ps
    Name                   Command                  State               Ports         
--------------------------------------------------------------------------------------
gitfab2_app_1   prehook ruby -v bundle ins ...   Up             0.0.0.0:3000->3000/tcp
gitfab2_db_1    docker-entrypoint.sh --inn ...   Up (healthy)   3306/tcp

Open https://localhost:3000 in your browser.

Create database

$ docker-compose run app bundle exec rails db:setup

Run tests

$ docker-compose run app bundle exec rails db:test:prepare
$ docker-compose run app bundle exec rspec

Build Production Environment

Edit Dockerfile.prod

Midify and run

$ vi config/Dockerfile.prod
$ docker build -t gitfab2 -f docker/Dockerfile.prod .
$ docker run -p 3000:3000 -e SECRET_KEY_BASE=xxxxxxxxxx gitfab2

Deploy with Kamal (over SSH)

Setup SSH

$ ssh-keygen -t ed25519
$ vi ~/.ssh/config
$ ssh gitfab2.host
Host  gitfab2.host
        HostName 123.456.789.012
        User deploy
        Port 22
        IdentitiesOnly yes
        IdentityFile ~/.ssh/fabble2024.deploy.id_ed25519

Install Kamal

https://kamal-deploy.org/docs/installation/

Ubuntu on WSL2

if [[ -f ~/.bashrc ]] ; then
    . ~/.bashrc
fi

if [ -z "$SSH_AUTH_SOCK" ]; then
   # Check for a currently running instance of the agent
   RUNNING_AGENT="`ps -ax | grep 'ssh-agent -s' | grep -v grep | wc -l | tr -d '[:space:]'`"
   if [ "$RUNNING_AGENT" = "0" ]; then
        # Launch a new instance of the agent
        ssh-agent -s &> $HOME/.ssh/ssh-agent
   fi
   eval `cat $HOME/.ssh/ssh-agent`
fi

ssh-add $HOME/.ssh/deploy.id_ed25519

alias kamal='docker run -it --rm -v "${PWD}:/workdir" -v "${SSH_AUTH_SOCK}:/ssh-agent" -v /var/run/docker.sock:/var/run/docker.sock -e "SSH_AUTH_SOCK=/ssh-agent" ghcr.io/basecamp/kamal:latest'

Deploy

$ kamal deploy

License

gitfab2 is released under the Apache License, Version 2.0.

Copyright 2017 WebDINO Japan.