Dockerfile or compose issue

I’m following this great setup: Docker image - setup uplinks - #5 by Ruben.Varela
Thank you @owen.campbell !

I can’t make it work with a basic project (my vega-lite JS clone working on Anvil.works).
Here are my files:

FROM python:3

RUN apt-get -yyy update && apt-get -yyy install software-properties-common && \
    wget -O- https://apt.corretto.aws/corretto.key | apt-key add - && \
    add-apt-repository 'deb https://apt.corretto.aws stable main'

RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
    (dpkg -i google-chrome-stable_current_amd64.deb || apt install -y --fix-broken) && \
    rm google-chrome-stable_current_amd64.deb 


RUN apt-get -yyy update && apt-get -yyy install java-1.8.0-amazon-corretto-jdk ghostscript

COPY ./requirements.txt ./
RUN pip install -r requirements.txt
RUN anvil-app-server || true

VOLUME /apps
WORKDIR /apps

RUN mkdir /anvil-data

RUN useradd anvil
RUN chown -R anvil:anvil /anvil-data
USER anvil

#ENTRYPOINT ["anvil-app-server", "--data-dir", "/anvil-data"]

#CMD ["--app", "MainApp"]

then I build it locally, my desktop is Ubuntu 21, and I run multiple containers.

requirements.txt is simply:
anvil-app-server

docker-compose.yml:

version: '3'
services:
  anvil:
    image: anvil:latest
    ports: 
      - 3030:3030
    volumes:
      - ./vegalite:/apps/vegalite
      - ./vegalite/.anvil-data:/anvil-data
    command: anvil-app-server --data-dir /anvil-data --app /apps/vegalite
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:3030 || exit 1"]
      interval: 20s
      timeout: 10s
      retries: 5

And the container crashes saying:

Failed to start built-in Postgres database: java.io.FileNotFoundException: /anvil-data/postgres-embedding.log (Permission denied)
More logs are available in /anvil-data/postgres.log.
Some common causes of this problem:
 - Are you launching this server as 'root' on a UNIX system? 
   Postgres will not run as root; try launching the server as an ordinary user.
 - Are you running this server on an unusual architecture or OS? (Linux/amd64)
Found Anvil App Server JAR in package directory

But using the docker stock image is working: docker run -v $PWD/vegalite:/apps/MainApp -p 3030:3030 anvilworks/anvil-app-server

Any idea what’s wrong with my setup?
Thank you

Hi @phm ,

I know it was probably with the best intentions, but it’s best you don’t direct questions to specific people.

It often has the opposite effect to the one intended, because most people like Owen are just regular users and it puts pressure on to help when they may not be able to, and other (possibly more suitable) people might not respond thinking the matter is in hand.

Hope you understand.

3 Likes

OK. I edited the only line asking him for help.
Does someone have any hints to help me?

I’d like to echo what @david.wylie said - we’re lucky to have such brilliant community members, but we shouldn’t take them for granted!

With regards to your errors - have you checked whether any of the error messages you’re seeing contain the answer? For example, are you running it as root, or is there anything relevant in the /anvil-data/postgres.log file?

Thanks @eli-anvil

To help you understand, my first message (about HTML field required) was read but I didn’t get any reply for days (and I’m still waiting for a reply), so I thought I should ask for help to helpful experts in their domains. I didn’t intend to offend others :slight_smile:

the log echoes the container error:
initdb: cannot be run as root. Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process.

but since it’s USER anvil in the dockerfile, I don’t get what’s missing.

I created the user on the host too.

Nothing obvious leaps out at me.

Often, when I’ve been building and rebuilding to get my Docker file right, I find dropping the anvil data directory helps.

1 Like

Thank you @owen.campbell

I finally understood a little bit more about my issue:
When I git clone, there’s no .anvil-data/
Therefore, in docker-compose.yml, the volumes section points to a non-existing local folder:
- ./CRUDnewsappwalkthrough/.anvil-data:/anvil-data

And at first run, for an unknown reason, the local folder is created by root (while dockerfile and docker-compose states that only the anvil user should be used).
I guess only command uses the user setting, not internal docker actions.

Since anvil user in the container is UID 1000, same as my local user, I manually created .anvil-data/, it did the trick. I now have the data folder populated, no postgres error, migration is done creating tables.

And now docker-compose runs … except that it results in a weird page:

The container logs:

Found Anvil App Server JAR in package directory
Found 2 migration(s) for (base runtime) DB.
Executing Anvil migrations...
Database currently at "2021-06-19-runtime-sessions"
0 migration(s) to perform.
Database now at "2021-06-19-runtime-sessions"
Migration complete.
[TRACE anvil.app-server.run] Invalidating; new version 1
[INFO  anvil.core.server] HTTP Server running on port 3030
[INFO  anvil.app-server.run] App URL:  http://localhost:3030
[INFO  anvil.app-server.dispatch] Launching built-in downlink...
[INFO  anvil.app-server.run] SMTP Server running on port 25
Connecting to ws://localhost:3030/_/downlink
Anvil websocket open
[INFO  anvil.executors.downlink] Downlink client connected with spec {:runtime "python3-full", :session_id "IBy8yul9FKInRkoOBdzh"}
Downlink authenticated OK
[INFO  anvil.app-server.run] [LOG :new-session] {:type browser}

Any idea?