Closed bverkron closed 2 years ago
I will try to reproduce. Thank you
I'm using blotdb and docker-compose and it works for me, here there are my files:
I'm using this docker-compose.yml:
{
"mysql": {
"host": "",
"user": "",
"pass": "",
"name": "",
"options": null
},
"bolt": {
"host": "/home/semaphore/database.boltdb",
"user": "",
"pass": "",
"name": "",
"options": null
},
"postgres": {
"host": "",
"user": "",
"pass": "",
"name": "",
"options": null
},
"dialect": "bolt",
"port": "80",
"interface": "",
"tmp_path": "/tmp/semaphore",
"cookie_hash": "KX/9eQL93a9Io/oz/qyAgcgfbih/NsdHmxD1y2w/+cI=",
"cookie_encryption": "KYPmjwQl5Y0yfeKPu+1dFqiQWSr5NlGGgCUfQrxrbuI=",
"access_key_encryption": "OS0drAmKZ8HrPrRlv52NdPhc/mmDaNdq9bBzp23CPjk=",
"email_sender": "",
"email_host": "",
"email_port": "",
"email_username": "",
"email_password": "",
"web_host": "",
"ldap_binddn": "",
"ldap_bindpassword": "",
"ldap_server": "",
"ldap_searchdn": "",
"ldap_searchfilter": "",
"ldap_mappings": {
"dn": "",
"mail": "",
"uid": "",
"cn": ""
},
"telegram_chat": "",
"telegram_token": "",
"max_parallel_tasks": 0,
"email_alert": false,
"email_secure": false,
"telegram_alert": false,
"ldap_enable": false,
"ldap_needtls": false,
"ssh_config_path": "",
"demo_mode": false
}
and this config.json file:
version: '2'
services:
semaphore:
#image: ansiblesemaphore/semaphore:v2.8.65
image: semaphoreui/semaphore:v2.8.65
container_name: semaphore
user: "1001:0"
volumes:
- ./config.json:/etc/semaphore/config.json
- ./database.boltdb:/home/semaphore/database.boltdb
- /share/oriol/semaphore:/tmp/semaphore/
command: ["/usr/local/bin/semaphore", "server", "--config", "/etc/semaphore/config.json"]
dns: 10.2.10.27
networks:
ymbihq_servers:
ipv4_address: 10.2.10.6
networks:
ymbihq_servers:
external: true
name: ymbihq_servers
command: ["/usr/local/bin/semaphore", "server", "--config", "/etc/semaphore/config.json"]
It works because you are overriding the CMD in the original image an bypassing the wrapper, similar to my workaround. I guess this can work if you’re providing your own config.json as you are (and as I attempted to do for my troubleshooting / work around) but it’s not documented anywhere as far as I can tell and has downsides. This may work but should not be required and is not by design.
How are you setting the UI username / password or what did it default to for you?
I reproduced issue. Thank you.
Yes, I overwrite the CMD.
For creating the password is this:
git clone ssh://git@git.oriolrius.cat:222/oriolrius/ansible-semaphore.git
cd ansible-semaphore
chown 1001.0 config.json
chown 1001.0 database.boltdb
docker-compose run semaphore sh
semaphore setup --config /etc/semaphore/config.json
semaphore user add --name oriol --login oriol --email MYEMAIL --password MYPASSOWRD --config /etc/semaphore/config.json
exit
docker-compose down
docker-compose up -d
I hope it was useful for you.
Regards. Oriol
command: ["/usr/local/bin/semaphore", "server", "--config", "/etc/semaphore/config.json"]
It works because you are overriding the CMD in the original image an bypassing the wrapper, similar to my workaround. I guess this can work if you’re providing your own config.json as you are (and as I attempted to do for my troubleshooting / work around) but it’s not documented anywhere as far as I can tell and has downsides. This may work but should not be required and is not by design.
How are you setting the UI username / password or what did it default to for you?
Fixing in progress. Thank you @bverkron
Awesome thank you! Let me know if I can help with testing or anything.
Yes, I overwrite the CMD.
For creating the password is this:
docker-compose run semaphore sh semaphore setup --config /etc/semaphore/config.json semaphore user add --name oriol --login oriol --email MYEMAIL --password MYPASSOWRD --config /etc/semaphore/config.json
Interesting approach. Not sure I can implement it quite like this being that I run from Portainer, at least not as part of the container spin up process via Portainer. But it might give me some ideas as a workaround until there's a fix. Though I'll probably just wait.
I believe I found the root cause of https://github.com/ansible-semaphore/semaphore/discussions/1040
Basically I've been trying unsuccessfully to get boltdb working in a container using the official image. No matter what environment variables I set in the docker-compose file I always get messages smiler to:
"Attempting to connect to database semaphore on 0.0.0.0:3306 with user semaphore ..."
It seems this is because the semaphore-wrapper does not account for boltdb and just assumed the DB will be either mysql or Postgres and it will have to connect to it. Of course with bolt there is nothing to "connect" to, at least not in the same way as mysql and Postgres with an ip and port number.
https://github.com/ansible-semaphore/semaphore/blob/0dd190dbcf2c8b96fcd9bb4cc759f4344ae3d32a/deployment/docker/common/semaphore-wrapper#L53
I have partially worked around this by writing a valid config to the expected location and skipping the semaphore-wrapper all together and it will successfully start up an semaphore instance and I can hit the UI. However, since my workaround bypasses the docker compose config (environment variable loading), I think, the username and password for the UI doesn't get set I cannot login to verify further.
Kind of grasping at straws here but I think I'm close. @fiftin or @mwxp06 are you able to verify if I'm on the right track and suggest a fix?