Hi,
Predrag Punosevac <punoseva...@gmail.com> wrote:

> Hi Misc,
> 
> Is anybody running Gogs 
> 
> https://gogs.io/
> 
> in production on OpenBSD using PostgreSQL as a backend. Any chance to
> share the installation/configuration notes with me?

Here are my notes (for both mariadb and postgresql from different
tests).  Note that, contrary to the gogs instructions for postgresql
the database user `git' is not allowed to create databases and the
`gogs_production' database is created by the database's `postgres' user.

Please don't copy and paste that won't work: some interaction is
needed.  I used Yuki Izumi's rc script but did not run gogs in
the build directory.

I edited the notes, please be aware there may be some mistyped
instructions.

Best regards
Robert


# gogs needs bash for some hooks.
pkg_add bash go git mariadb-server postgresql-server zip unzip-6.0p9
# zip for `make pack'


## MariaDB setup
cat >> /etc/login.conf <<EOF
mysqld:\
        :openfiles-cur=1024:\
        :openfiles-max=2048:\
        :tc=daemon:

EOF
[ -f /etc/login.conf.db ] && cap_mkdb /etc/login.conf

/usr/local/bin/mysql_install_db
rcctl start mysqld

# run mysql_secure_installation; among others to set the mysql root
# password
/usr/local/bin/mysql_secure_installation
# ^-- ENTER, ENTER mariadbrootpw mariadbrootpw ENTER ENTER ENTER ENTER

mysql -u root -p <<EOF
create database gogs CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
grant index, create, select, insert, update, delete, drop, alter, lock
tables on gogs.* to 'gogsuser'@'localhost' identified by '123';
quit
EOF
# ^-- have to enter mariadbrootpw




## PostgreSQL setup
cat >> /etc/login.conf <<EOF
postgresql:\
        :openfiles=768:\
        :tc=daemon:

EOF
[ -f /etc/login.conf.db ] && cap_mkdb /etc/login.conf
su - _postgresql
mkdir /var/postgresql/data
initdb -D /var/postgresql/data -U postgres -E UTF8 -A md5 -W
# ^-- postgresqlrootpw postgresqlrootpw

rcctl start postgresql
createuser -E -l -P -U postgres git
# ^-- postgresqlgitpw postgresqlgitpw postgresqlrootpw

# v-- postgresqlrootpw
psql -d template1 -U postgres

CREATE DATABASE gogs_production OWNER git;
\q
exit



## Creating `git' user; making and `installing' gogs
useradd -L daemon -m -c "Gogs" git 
su - git
go get -u github.com/gogits/gogs

cd $GOPATH/src/github.com/gogits/gogs
go build

# creating release package
make pack
cp release/gogs..zip ~/gogs.zip

# Is should be Ok th delete the go/ directory used for building gogs,
# now

# unpacking the release
cd
unzip gogs.zip



# next steps for creating custom config file are probably not
# necessary
mkdir -p gogs/custom/conf
HOSTNAME=gogs.example.com
cat > gogs/custom/conf/app.ini <<EOF
[database]
DB_TYPE = postgres
HOST = 127.0.0.1:5432
NAME = gogs_production
USER = git
PASSWD = postgresqlgitpw
PATH = data/gogs.db
APP_NAME = orgmode.org
RUN_USER = git
RUN_MODE = prod

[repository]
ROOT = /home/git/gogs-repositories

[server]
DOMAIN       = ${HOSTNAME}
HTTP_PORT    = 3000
ROOT_URL     = http://${HOSTNAME}:3000/
DISABLE_SSH  = false
SSH_PORT     = 22
OFFLINE_MODE = false

[mailer]
ENABLED = false

[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL     = false
DISABLE_REGISTRATION   = false
ENABLE_CAPTCHA         = true
REQUIRE_SIGNIN_VIEW    = false

[picture]
DISABLE_GRAVATAR = false

[session]
PROVIDER = file

[log]
MODE      = file
LEVEL     = Info
ROOT_PATH = /home/git/gogs/log

EOF

# creating rc file
cat >/etc/rc.d/gogs <<EOF
#! /bin/sh

daemon="/home/git/gogs/gogs"
daemon_user="git"

. /etc/rc.d/rc.subr

rc_reload=NO

rc_cmd $1
EOF

# enable and start gogs
rcctl enable gogs
rcctl start gogs


# goto localhost:3000 and configure gogs.  (probably don't need manual
# creation of custom/conf/app.ini)

Reply via email to