Skip to content

Commit

Permalink
chore: make Docker environment easier to work with (#24)
Browse files Browse the repository at this point in the history
- Substitutes admin token directly in `.env`
- Sets ownership of `docker/synapse` to the user executing `docker`
(this requires the directory to be present and owned by the user,
otherwise docker will create it for us and set ownership to root)

<!--
Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->
  • Loading branch information
avdb13 authored Feb 13, 2024
1 parent b2d6546 commit 1adb585
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ nuke_db:
# Generates the synapse configuration file and saves it
gen_synapse_conf: dotenv
docker run -i --rm \
-u $(id -u):$(id -g) \
-v ./docker/synapse:/data \
--env-file .env \
matrixdotorg/synapse:v1.96.1 generate
Expand All @@ -37,15 +38,18 @@ gen_synapse_conf: dotenv
gen_synapse_admin: dotenv
docker compose exec -i synapse \
register_new_matrix_user http://localhost:8008 \
-u $(id -u):$(id -g) \
-c /data/homeserver.yaml \
-u admin \
-p admin \
-a

# Retrieves admin access token uses de-facto admin user and Development Database Credentials
get_access_token:
curl -sS -d '{"type":"m.login.password", "user":"admin", "password":"admin"}' \
http://localhost:8008/_matrix/client/v3/login | jq --raw-output '.access_token' > access_token.txt
sed -i "s/COMMUNE_SYNAPSE_ADMIN_TOKEN='.*'/COMMUNE_SYNAPSE_ADMIN_TOKEN='$( \
curl -sS -d '{"type":"m.login.password", "user":"admin", "password":"admin"}' \
http://localhost:8008/_matrix/client/v3/login | jq --raw-output '.access_token' \
)'/" .env

# Runs backend dependency services
backend: dotenv
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
- '8001:8001'
volumes:
- redis-state:/data

synapse_database:
image: 'postgres:16'
ports:
Expand All @@ -27,6 +27,7 @@ services:

synapse:
image: 'ghcr.io/element-hq/synapse:v1.100.0'
user: '${UID:-1000}:${GID:-1000}'
ports:
- '8008:8008'
- '8448:8448'
Expand Down
Empty file added docker/synapse/.gitkeep
Empty file.

0 comments on commit 1adb585

Please sign in to comment.