What I needed was to be able to deploy to multiple environments (development, staging, production) with CI, using rev-managed configurations. I figure I will share my solution here in case it helps you.
- I packaged this util function in my docker file by adding the following to dockerfile:
RUN go build contrib/environment-to-ini/environment-to-ini.go
...
COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
This takes any environment variables in the form: GITEA__section__KEY
and sets them in app.ini
- super helpful!
- I use multiple docker-compose files to mix in the settings I want using a
.env
file on the host. For example:
TAG="${DRONE_COMMIT_SHA:0:7}" docker-compose \
-f docker-compose.yml \
-f docker-compose.staging.yml \
-f docker-compose.mailer.yml up -d
My docker-compose.yml
file contains the base settings I want to use common to all deployments. If I want to enable the mailer I just add the mailer config file above. For instance, the mailer config looks like this:
version: "3"
# Use this mixin to add smtp mail server
services:
server:
environment:
- GITEA__mailer__ENABLED=true
- GITEA__mailer__FROM=${GITEA__mailer__FROM:?GITEA__mailer__FROM not set}
- GITEA__mailer__MAILER_TYPE=smtp
- GITEA__mailer__HOST=${GITEA__mailer__HOST:?GITEA__mailer__HOST not set}
- GITEA__mailer__IS_TLS_ENABLED=true
- GITEA__mailer__USER=${GITEA__mailer__USER:-apikey}
- GITEA__mailer__PASSWD="""${GITEA__mailer__PASSWD:?GITEA__mailer__PASSWD not set}"""
The :?
key will fail docker-compose if any of those env variables are not set.
- I set the the
TOKEN
s using gitea generate and save them on the host.env
file - Finally, my endpoint (
/etc/s6/gitea/setup
) is changed to:
environment-to-ini --config ${GITEA_CUSTOM}/conf/app.ini \
--prefix "ALLSPICE"
chown ${USER}:git ${GITEA_CUSTOM}/conf/app.ini