Edit: for suggestions in deploying listmonk, skip to the code at the end of this post
I’m quite inexperienced with Docker and new to Fly.io. I’d be grateful for help getting my app deployed.
I’m trying to adapt a Dockerfile and config script for Railway.app. This Dockerfile successfully deploys listmonk on Railway.
Dockerfile
:
FROM listmonk/listmonk:latest
ARG PORT ADMIN_PASSWORD ADMIN_USERNAME PGDATABASE PGHOST PGPASSWORD PGPORT PGUSER
COPY config.sh ./config.sh
RUN chmod +x ./config.sh && ./config.sh
RUN ./listmonk --idempotent --yes --upgrade || ./listmonk --install --yes --upgrade
config.sh
:
echo "
[app]
address = \"0.0.0.0:${PORT}\"
admin_username = \"${ADMIN_USERNAME}\"
admin_password = \"${ADMIN_PASSWORD}\"
# Database.
[db]
host = \"${PGHOST}\"
port = ${PGPORT}
user = \"${PGUSER}\"
password = \"${PGPASSWORD}\"
database = \"${PGDATABASE}\"
ssl_mode = \"disable\"
max_open = 25
max_idle = 25
max_lifetime = \"300s\"
" > config.toml
When I attempt to launch, I get a panic at the final RUN command with the following relevant lines:
=> ERROR [5/5] RUN ./listmonk --idempotent --yes --upgrade || ./listmonk 0.4s
------
> [5/5] RUN ./listmonk --idempotent --yes --upgrade || ./listmonk --install --yes --upgrade:
#8 0.365 2022/10/06 16:39:15 main.go:95: v2.2.0 (bbbf28c 2022-07-30T18:18:24Z)
#8 0.365 2022/10/06 16:39:15 init.go:128: reading config: config.toml
#8 0.368 panic: unhandled token: "user" [recovered]
#8 0.368 panic: interface conversion: interface {} is *errors.errorString, not string
What I’ve done/tried after spending hours searching for answers here and elsewhere:
I’ve added all the secrets with flyctl secrets set PGUSER=someuser PGPASSWORD=blablabla ...
I’ve tried adding one or both of the following to the Dockerfile:
ENV PORT=${PORT} ADMINPORT=${ADMINPORT} ADMIN_PASSWORD=${ADMIN_PASSWORD} ADMIN_USERNAME=${ADMIN_USERNAME} POSTGRES_DATABASE=${POSTGRES_DATABASE} POSTGRES_HOST=${POSTGRES_HOST} POSTGRES_PASSWORD=${POSTGRES_PASSWORD} POSTGRES_PORT=${POSTGRES_PORT} POSTGRES_USER=${POSTGRES_USER}
RUN --mount=type=secret,id=PORT --mount=type=secret,id=ADMIN_PASSWORD --mount=type=secret,id=ADMIN_USERNAME --mount=type=secret,id=POSTGRES_DATABASE --mount=type=secret,id=POSTGRES_HOST --mount=type=secret,id=POSTGRES_PASSWORD --mount=type=secret,id=POSTGRES_PORT --mount=type=secret,id=POSTGRES_USER
and I’ve tried running docker deploy
as well as:
flyctl deploy --build-arg PORT=$PORT --build-arg ADMINPORT=$ADMINPORT --build-arg ADMIN_PASSWORD=$ADMIN_PASSWORD --build-arg ADMIN_USERNAME=$ADMIN_USERNAME --build-arg POSTGRES_DATABASE=$POSTGRES_DATABASE --build-arg POSTGRES_HOST=$POSTGRES_HOST --build-arg POSTGRES_PASSWORD=$POSTGRES_PASSWORD --build-arg POSTGRES_PORT=$POSTGRES_PORT --build-arg POSTGRES_USER=$POSTGRES_USER
Still, I always get the same error.
If I remove the line referencing user
in the Dockerfile, the error that mentions user
changes to the next item, password
.
Any help would be greatly appreciated!