sameersbn / docker-gitlab-ci

Dockerfile to build a GitLab CI container image.
http://www.damagehead.com/docker-gitlab-ci/
MIT License
199 stars 51 forks source link

Does not start when merged with gitlab fig.yml #17

Closed jar349 closed 9 years ago

jar349 commented 9 years ago

I'm trying to merge the fig.yml from your gitlab repo with the fig.yml with this repo.

Here's my fig.yml:

postgresql:
    image: sameersbn/postgresql:9.1-1
    environment:
        - DB_USER=gitlab
        - DB_PASS=secretpassword
        - DB_NAME=gitlabhq_production
gitlab:
    image: sameersbn/gitlab:7.7.2
    links:
        - redis:redisio
        - postgresql:postgresql
    ports:
        - "10080:80"
        - "10022:22"
redis:
    image: sameersbn/redis:latest
ci:
    image: sameersbn/gitlab-ci:5.4.2
    links:
        - redis:redisio
        - postgresql:postgresql
        - gitlab:gitlab
    ports:
        - "10081:80"
    environment:
        - GITLAB_CI_HOST=localhost:10081
        - GITLAB_URL=http://localhost:10080
        - GITLAB_APP_ID='<removed>'
        - GITLAB_APP_SECRET='<removed>'

When I run sudo fig up I get:

ci_1         | Waiting for database server to accept connections
ci_1         | Migrating database...
ci_1         | rake aborted!
ci_1         | Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 3 column 5
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/settingslogic-2.0.9/lib/settingslogic.rb:103:in `initialize'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/settingslogic-2.0.9/lib/settingslogic.rb:60:in `new'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/settingslogic-2.0.9/lib/settingslogic.rb:60:in `instance'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/settingslogic-2.0.9/lib/settingslogic.rb:37:in `[]'
ci_1         | /home/gitlab_ci/gitlab-ci/config/initializers/1_settings.rb:32:in `<top (required)>'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.10/lib/active_support/dependencies.rb:223:in `load'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.10/lib/active_support/dependencies.rb:223:in `block in load'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.10/lib/active_support/dependencies.rb:214:in `load_dependency'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.10/lib/active_support/dependencies.rb:223:in `load'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/engine.rb:609:in `block (2 levels) in <class:Engine>'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/engine.rb:608:in `each'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/engine.rb:608:in `block in <class:Engine>'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/initializable.rb:30:in `instance_exec'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/initializable.rb:30:in `run'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/initializable.rb:55:in `block in run_initializers'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/initializable.rb:44:in `each'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/initializable.rb:44:in `tsort_each_child'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/initializable.rb:54:in `run_initializers'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/application.rb:215:in `initialize!'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
ci_1         | /home/gitlab_ci/gitlab-ci/config/environment.rb:5:in `<top (required)>'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.10/lib/active_support/dependencies.rb:229:in `require'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.10/lib/active_support/dependencies.rb:229:in `block in require'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.10/lib/active_support/dependencies.rb:214:in `load_dependency'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.10/lib/active_support/dependencies.rb:229:in `require'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/application.rb:189:in `require_environment!'
ci_1         | /home/gitlab_ci/gitlab-ci/vendor/bundle/ruby/2.1.0/gems/railties-4.0.10/lib/rails/application.rb:260:in `block in run_tasks_blocks'
ci_1         | Tasks: TOP => db:migrate => environment
ci_1         | (See full trace by running task with --trace)
gitlab_ci_1 exited with code 1
Gracefully stopping... (press Ctrl+C again to force)
Stopping gitlab_gitlab_1...
Stopping gitlab_redis_1...
Stopping gitlab_postgresql_1...
sameersbn commented 9 years ago

@jar349 you need to create a database for gitlab-ci as well. sameersbn/postgresql:9.1-2 and above allows you to create multiple databases at launch. However, when multiple databases are created you need to specify the DB_NAME parameter in env of the gitlab and gitlab-ci containers.

postgresql:
    image: sameersbn/postgresql:9.4
    environment:
        - DB_USER=gitlab
        - DB_PASS=secretpassword
        - DB_NAME=gitlabhq_production,gitlabci_production
gitlab:
    image: sameersbn/gitlab:7.7.2
    links:
        - redis:redisio
        - postgresql:postgresql
    ports:
        - "10080:80"
        - "10022:22"
    environment:
        - DB_NAME=gitlabhq_production
redis:
    image: sameersbn/redis:latest
ci:
    image: sameersbn/gitlab-ci:5.4.2
    links:
        - redis:redisio
        - postgresql:postgresql
        - gitlab:gitlab
    ports:
        - "10081:80"
    environment:
        - DB_NAME=gitlabci_production
        - GITLAB_CI_HOST=localhost:10081
        - GITLAB_URL=http://localhost:10080
        - GITLAB_APP_ID='<removed>'
        - GITLAB_APP_SECRET='<removed>'
jar349 commented 9 years ago

Thanks for your response! I'm using your updates and now I get this stack trace:

postgresql_1 | Creating user "gitlab"...
postgresql_1 | Creating database "gitlabhq_production"...
postgresql_1 | Granting access to database "gitlabhq_production" for user "gitlab"...
postgresql_1 | Creating database "gitlabci_production"...
postgresql_1 | Granting access to database "gitlabci_production" for user "gitlab"...
postgresql_1 | Starting PostgreSQL server...
postgresql_1 | 2015-02-14 16:21:33 UTC [82-1] LOG:  database system was shut down at 2015-02-14 16:21:33 UTC
postgresql_1 | 2015-02-14 16:21:33 UTC [86-1] LOG:  autovacuum launcher started
postgresql_1 | 2015-02-14 16:21:33 UTC [81-1] LOG:  database system is ready to accept connections
gitlab_1     | Waiting for database server to accept connections.
ci_1         | Waiting for database server to accept connections..
gitlab_1     | Setting up GitLab for firstrun. Please be patient, this could take a while...
ci_1         | Setting up GitLab CI for firstrun. Please be patient, this could take a while...
postgresql_1 | 2015-02-14 16:21:37 UTC [92-1] gitlab@postgres ERROR:  database "gitlabci_production" already exists
postgresql_1 | 2015-02-14 16:21:37 UTC [92-2] gitlab@postgres STATEMENT:  CREATE DATABASE "gitlabci_production" ENCODING = 'unicode'
ci_1         | gitlabci_production already exists
ci_1         | rake aborted!
ci_1         | Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 3 column 5
sameersbn commented 9 years ago

I have not problem starting gitlab and gitlab-ci using the fig.yml. Please check if you are running out of RAM. Below are my logs

# fig up
Creating Desktop_postgresql_1...
Creating Desktop_redis_1...
Creating Desktop_gitlab_1...
Creating Desktop_ci_1...
Attaching to Desktop_postgresql_1, Desktop_redis_1, Desktop_gitlab_1, Desktop_ci_1
postgresql_1 | /start: line 35: [: =: unary operator expected
postgresql_1 | Initializing database...
redis_1      |                 _._                                                  
redis_1      |            _.-``__ ''-._                                             
redis_1      |       _.-``    `.  `_.  ''-._           Redis 2.8.4 (00000000/0) 64 bit
redis_1      |   .-`` .-```.  ```\/    _.,_ ''-._                                   
redis_1      |  (    '      ,       .-`  | `,    )     Running in stand alone mode
redis_1      |  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
redis_1      |  |    `-._   `._    /     _.-'    |     PID: 12
redis_1      |   `-._    `-._  `-./  _.-'    _.-'                                   
redis_1      |  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
redis_1      |  |    `-._`-._        _.-'_.-'    |           http://redis.io        
redis_1      |   `-._    `-._`-.__.-'_.-'    _.-'                                   
redis_1      |  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
redis_1      |  |    `-._`-._        _.-'_.-'    |                                  
redis_1      |   `-._    `-._`-.__.-'_.-'    _.-'                                   
redis_1      |       `-._    `-.__.-'    _.-'                                       
redis_1      |           `-._        _.-'                                           
redis_1      |               `-.__.-'                                               
redis_1      | 
redis_1      | [12] 15 Feb 03:09:01.209 # Server started, Redis version 2.8.4
redis_1      | [12] 15 Feb 03:09:01.209 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1      | [12] 15 Feb 03:09:01.209 * The server is now ready to accept connections on port 6379
redis_1      | [12] 15 Feb 03:09:01.209 * The server is now ready to accept connections at /var/run/redis/redis.sock
gitlab_1     | debconf: unable to initialize frontend: Dialog
gitlab_1     | debconf: (TERM is not set, so the dialog frontend is not usable.)
gitlab_1     | debconf: falling back to frontend: Readline
gitlab_1     | debconf: unable to initialize frontend: Readline
gitlab_1     | debconf: (This frontend requires a controlling tty.)
gitlab_1     | debconf: falling back to frontend: Teletype
gitlab_1     | Creating SSH2 RSA key; this may take some time ...
gitlab_1     | Creating SSH2 DSA key; this may take some time ...
gitlab_1     | Creating SSH2 ECDSA key; this may take some time ...
gitlab_1     | Creating SSH2 ED25519 key; this may take some time ...
gitlab_1     | invoke-rc.d: policy-rc.d denied execution of restart.
postgresql_1 | |------------------------------------------------------------------|
postgresql_1 | | PostgreSQL User: postgres, Password: aeh1aeQuu6bi3i              |
postgresql_1 | |                                                                  |
postgresql_1 | | To remove the PostgreSQL login credentials from the logs, please |
postgresql_1 | | make a note of password and then delete the file pwfile          |
postgresql_1 | | from the data store.                                             |
postgresql_1 | |------------------------------------------------------------------|
postgresql_1 | Creating user "gitlab"...
postgresql_1 | Creating database "gitlabhq_production"...
postgresql_1 | Granting access to database "gitlabhq_production" for user "gitlab"...
postgresql_1 | Creating database "gitlabci_production"...
postgresql_1 | Granting access to database "gitlabci_production" for user "gitlab"...
postgresql_1 | Starting PostgreSQL server...
postgresql_1 | 2015-02-15 03:09:20 UTC [80-1] LOG:  database system was shut down at 2015-02-15 03:09:20 UTC
postgresql_1 | 2015-02-15 03:09:20 UTC [81-1] gitlab@gitlabhq_production FATAL:  the database system is starting up
postgresql_1 | 2015-02-15 03:09:20 UTC [85-1] LOG:  autovacuum launcher started
postgresql_1 | 2015-02-15 03:09:20 UTC [79-1] LOG:  database system is ready to accept connections
ci_1         | Waiting for database server to accept connections........
ci_1         | Setting up GitLab CI for firstrun. Please be patient, this could take a while...
gitlab_1     | Waiting for database server to accept connections.....
gitlab_1     | Setting up GitLab for firstrun. Please be patient, this could take a while...
postgresql_1 | 2015-02-15 03:09:46 UTC [91-1] gitlab@postgres ERROR:  database "gitlabci_production" already exists
postgresql_1 | 2015-02-15 03:09:46 UTC [91-2] gitlab@postgres STATEMENT:  CREATE DATABASE "gitlabci_production" ENCODING = 'unicode'
ci_1         | gitlabci_production already exists
ci_1         | Migrating database...
ci_1         | 2015-02-15 03:10:02,797 CRIT Supervisor running as root (no user in config file)
ci_1         | 2015-02-15 03:10:02,798 WARN Included extra file "/etc/supervisor/conf.d/sidekiq.conf" during parsing
ci_1         | 2015-02-15 03:10:02,798 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
ci_1         | 2015-02-15 03:10:02,798 WARN Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
ci_1         | 2015-02-15 03:10:02,798 WARN Included extra file "/etc/supervisor/conf.d/unicorn.conf" during parsing
ci_1         | 2015-02-15 03:10:03,020 INFO RPC interface 'supervisor' initialized
ci_1         | 2015-02-15 03:10:03,020 CRIT Server 'unix_http_server' running without any HTTP authentication checking
ci_1         | 2015-02-15 03:10:03,020 INFO supervisord started with pid 1
ci_1         | 2015-02-15 03:10:04,024 INFO spawned: 'sidekiq' with pid 149
ci_1         | 2015-02-15 03:10:04,028 INFO spawned: 'unicorn' with pid 150
ci_1         | 2015-02-15 03:10:04,030 INFO spawned: 'cron' with pid 151
ci_1         | 2015-02-15 03:10:04,032 INFO spawned: 'nginx' with pid 152
ci_1         | 2015-02-15 03:10:05,247 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
ci_1         | 2015-02-15 03:10:05,247 INFO success: unicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
ci_1         | 2015-02-15 03:10:05,247 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
ci_1         | 2015-02-15 03:10:05,247 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
postgresql_1 | 2015-02-15 03:10:13 UTC [96-1] gitlab@postgres ERROR:  database "gitlabhq_production" already exists
postgresql_1 | 2015-02-15 03:10:13 UTC [96-2] gitlab@postgres STATEMENT:  CREATE DATABASE "gitlabhq_production" ENCODING = 'unicode'
gitlab_1     | gitlabhq_production already exists
gitlab_1     | Migrating database...
gitlab_1     | Compiling assets. Please be patient, this could take a while...
...
...
gitlab_1     | Starting supervisord...
gitlab_1     | 2015-02-15 03:13:00,713 CRIT Supervisor running as root (no user in config file)
gitlab_1     | 2015-02-15 03:13:00,713 WARN Included extra file "/etc/supervisor/conf.d/sidekiq.conf" during parsing
gitlab_1     | 2015-02-15 03:13:00,713 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
gitlab_1     | 2015-02-15 03:13:00,713 WARN Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
gitlab_1     | 2015-02-15 03:13:00,713 WARN Included extra file "/etc/supervisor/conf.d/unicorn.conf" during parsing
gitlab_1     | 2015-02-15 03:13:00,713 WARN Included extra file "/etc/supervisor/conf.d/sshd.conf" during parsing
gitlab_1     | 2015-02-15 03:13:00,818 INFO RPC interface 'supervisor' initialized
gitlab_1     | 2015-02-15 03:13:00,818 CRIT Server 'unix_http_server' running without any HTTP authentication checking
gitlab_1     | 2015-02-15 03:13:00,818 INFO supervisord started with pid 1
gitlab_1     | 2015-02-15 03:13:01,822 INFO spawned: 'sidekiq' with pid 417
gitlab_1     | 2015-02-15 03:13:01,826 INFO spawned: 'unicorn' with pid 418
gitlab_1     | 2015-02-15 03:13:01,829 INFO spawned: 'cron' with pid 419
gitlab_1     | 2015-02-15 03:13:01,831 INFO spawned: 'nginx' with pid 420
gitlab_1     | 2015-02-15 03:13:01,833 INFO spawned: 'sshd' with pid 421
gitlab_1     | 2015-02-15 03:13:03,790 INFO success: sidekiq entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1     | 2015-02-15 03:13:03,791 INFO success: unicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1     | 2015-02-15 03:13:03,791 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1     | 2015-02-15 03:13:03,791 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
gitlab_1     | 2015-02-15 03:13:03,791 INFO success: sshd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
redis_1      | [12] 15 Feb 03:14:02.064 * 10 changes in 300 seconds. Saving...
redis_1      | [12] 15 Feb 03:14:02.065 * Background saving started by pid 15
redis_1      | [15] 15 Feb 03:14:02.163 * DB saved on disk
redis_1      | [15] 15 Feb 03:14:02.164 * RDB: 6 MB of memory used by copy-on-write
redis_1      | [12] 15 Feb 03:14:02.166 * Background saving terminated with success
jar349 commented 9 years ago

I deleted the old containers with fig rm and ran fig up again and it worked this time. Now everything starts and I can log into gitlab.

I created an application in gitlab called GitLab CI and set the callback url to http://localhost:10080/user_sessisons/callback as per the gitlab_ci documentation. I then took the app id and secret and added them to the fig.yml. Then I called fig stop and fig start so that gitlab_ci would pick up the changes. However, when I try to log into gitlab_ci, I get the following error:

Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.

sameersbn commented 9 years ago

@jar349 fig does not update the container environment after fig.yml it is updated. You might have to manually remove the gitlab_ci container before running fig up again.

jar349 commented 9 years ago

@sameersbn I had that same thought. What I did:

  1. fig rm to remove everything
  2. edit fig.yml and comment out the entire ci section
  3. run fig up to create redis, postgres, and gitlab
  4. log into gitlab and create an application for gitlab_ci
  5. run fig stop to stop all containers
  6. edit fig.yml to uncomment the ci section and include the app_id and secret
  7. run fig up so that gitlab_ci gets created for the first time -- with the app_id!

Result: same problem as before -> Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.

When you run this yourself, have you successfully logged into gitlab_ci, or have you not tried it?

sameersbn commented 9 years ago

@jar349 I use both gitlab and gitlab-ci. I do not use fig though. In my setup I am able to login to gitlab-ci via the gitlab oauth no problem.

I have not tried this using fig.

ebuildy commented 9 years ago

I am running the same issue, a fresh gitlab + gitlab ci install via the same fig.yml.

The Oauth URL is:

http://index.dev:10080/oauth/authorize?client_id=%27&redirect_uri=http%3A%2F%2Findex.dev%3A10081%2Fuser_sessions%2Fcallback&response_type=code

Should I configure something in Gitlab settings?

ebuildy commented 9 years ago

Ho, actually you must setup an Oauth application on your gitlab AND set

GITLAB_APP_ID
GITLAB_APP_SECRET

On your fig.yml, for CI container.