Preseed configuration via ENV #1158

Open
titpetric opened this Issue Jan 5, 2017 · 2 comments

Projects

None yet

2 participants

@titpetric
titpetric commented Jan 5, 2017 edited

Hi guys!

It would be really nice if one could pre-seed the mongodb database with ENV variables. Currently, db/seeds.rb has some "hard-coded" values, and generates a password uniquely. I am slightly working around it by creating a Makefile of my own:

build: seed
        -docker rmi -f $(NAME)
        docker build --rm -t $(NAME) errbit/
        -docker-cleanup

errbit:
        git clone https://github.com/errbit/errbit.git

seed: errbit
        perl -pi -e 's/^admin_username.+/admin_username = "defaultuser"/g' errbit/db/seeds.rb
        perl -pi -e 's/^admin_email.+/admin_email = "defaultemail"/g' errbit/db/seeds.rb
        perl -pi -e 's/^admin_pass.+/admin_pass = "defaultpass"/g' errbit/db/seeds.rb

.PHONY: build seed

Maybe I'm just not understanding correctly how to override these If I want?

@titpetric

Hack2, since I'm building a docker image, this Dockerfile:

FROM errbit/errbit

ARG ERRBIT_ADMIN_USERNAME=admin
ARG ERRBIT_ADMIN_PASS=admin
ARG ERRBIT_ADMIN_EMAIL="errbit@example.com"

ENV ERRBIT_ADMIN_USERNAME=${ERRBIT_ADMIN_USERNAME} ERRBIT_ADMIN_PASS=${ERRBIT_ADMIN_PASS} ERRBIT_ADMIN_EMAIL=${ERRBIT_ADMIN_EMAIL}

RUN     sed -i "s/^admin_username.*/admin_username = \"${ERRBIT_ADMIN_USERNAME}\"/" db/seeds.rb && \
        sed -i "s/^admin_email.*/admin_email = \"${ERRBIT_ADMIN_EMAIL}\"/" db/seeds.rb && \
        sed -i "s/^admin_pass.*/admin_pass = \"${ERRBIT_ADMIN_PASS}\"/" db/seeds.rb
@stevecrozz
Member

This seems like a good idea.

@stevecrozz stevecrozz added the feature label Jan 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment