This is a demo of how you can run Authgear with Docker Compose locally. This setup is NOT intended for production use.
Add the following to /etc/hosts
127.0.0.1 accounts.localhost
127.0.0.1 portal.localhost
docker compose up -d postgres redis miniodocker compose run --rm -it authgear authgear database migrate up
docker compose run --rm -it authgear authgear audit database migrate up
docker compose run --rm -it authgear authgear images database migrate up
docker compose run --rm -it authgear-portal authgear-portal database migrate upRun this command to enter the container.
docker compose exec -it minio bashInside the container, do these
mc alias set local http://localhost:9000 "$MINIO_ROOT_USER" "$MINIO_ROOT_PASSWORD"
mc mb local/images
mc mb local/userexportPress CTRL-D to exit the container
docker compose updocker compose run --rm --workdir "/work" -v "$PWD/accounts:/work" authgear authgear init --interactive=false \
--purpose=portal \
--for-helm-chart=true \
--app-id="accounts" \
--public-origin="http://accounts.localhost:3100" \
--portal-origin="http://portal.localhost:8010" \
--portal-client-id=portal \
--phone-otp-mode=sms \
--disable-email-verification=true \
--search-implementation=postgresql \
-o /workdocker compose run --rm --workdir "/work" -v "$PWD/accounts:/work" authgear-portal authgear-portal internal configsource create /work
docker compose run --rm authgear-portal authgear-portal internal domain create-default --default-domain-suffix ".localhost"Important
The email used in this step is user@example.com while the password is secretpassword.
Feel free to adjust the email or the password.
docker compose exec authgear authgear internal admin-api invoke \
--app-id accounts \
--endpoint "http://127.0.0.1:3002" \
--host "accounts.localhost:3100" \
--query '
mutation createUser($email: String!, $password: String!) {
createUser(input: {
definition: {
loginID: {
key: "email"
value: $email
}
}
password: $password
}) {
user {
id
}
}
}
' \
--variables-json '{"email":"user@example.com","password":"secretpassword"}'It should output something like
{"data":{"createUser":{"user":{"id":"VXNlcjoyMDhkYWFkYy0wZmM4LTQ1Y2MtODQwNS01ODIzNTVmYTI0ZWU"}}}}
Take note of the user node ID.
Important
The literal user node ID used here is NOT intended for copy-and-paste directly. You have to replace it with the user node ID you obtained in the previous step.
echo "VXNlcjoyMDhkYWFkYy0wZmM4LTQ1Y2MtODQwNS01ODIzNTVmYTI0ZWU" | basenc --base64url --decodeIt should output something like
User:208daadc-0fc8-45cc-8405-582355fa24ee
Take note of the user raw ID.
Important
The literal user raw ID used here is NOT intended for copy-and-paste directly. You have to replace it with the user raw ID you obtained in the previous step.
docker compose run --rm authgear-portal authgear-portal internal collaborator add --app-id accounts --user-id 208daadc-0fc8-45cc-8405-582355fa24ee --role ownerVisit http://portal.localhost:8010 and sign in with your account created in a previous step.
You need not go through the steps again if you shut down server, and want to restart.
You just run
docker compose up