It fails with:
=> ERROR [4/9] RUN apt-get -yyy update && apt-get -yyy install java-1.8.0-amazon-corretto-jdk ghostscript
3.026 E: Unable to locate package java-1.8.0-amazon-corretto-jdk
3.026 E: Couldn’t find any package by glob ‘java-1.8.0-amazon-corretto-jdk’
3.026 E: Couldn’t find any package by regex ‘java-1.8.0-amazon-corretto-jdk’
@owen.campbell the real issue was in my case the base image.
I used in my original Dockerfile:
FROM python:3
That image somehow stopped supporting that java corretto package.
I changed first line in my Dockerfile to the base image that anvil repo is using:
FROM --platform=linux/amd64 python:3-buster
Finally after some more testing I switched to different base image.
That one has a native package openjdk-17 and works fine so far.
Below sample dockerfile
FROM python:3.11-slim-bookworm
RUN apt-get -yyy update && apt-get -yyy install openjdk-17-jdk
RUN pip install --upgrade pip
RUN pip install anvil-app-server
RUN anvil-app-server || true
RUN mkdir /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"]
After some wrangling with multi-architecture builds, I’ve managed to use your code to fix the problems on amoni. If you’re interested, the result is at:
I was playing also with smaller image size by using Alpine as base image:
FROM python:3.11-alpine
But this one is based on Ubuntu and some things are slightly different.
Instead “useradd” command I had to use “adduser” with “-D” for skipping the password when creating the user.
Also the package name is different for java - “openjdk8”.
Had to add also “gcc”, “python-dev” and “linux-headers” to have the “psutil” package build.
I was testing that on raspberry pi
Final base dockerfile is like that:
FROM python:3.11-alpine
RUN apk update && apk add --no-cache build-base linux-headers gcc python3-dev
RUN apk add --update openjdk8
RUN pip install --upgrade pip
RUN pip install --no-cache-dir psutil
RUN pip install anvil-app-server
RUN anvil-app-server || true
RUN mkdir /apps
WORKDIR /apps
RUN mkdir /anvil-data
RUN adduser anvil -D
RUN chown -R anvil:anvil /anvil-data
USER anvil
ENTRYPOINT ["anvil-app-server", "--data-dir", "/anvil-data"]
CMD ["--app", "MainApp"]
Here is also code for uplink script as docker container, might be useful to someone.
This is really small in size 160MB as its using “slim” version of the image.
# Use an official Python runtime as a parent image
FROM python:3.11-slim-bookworm
# Install Anvil Uplink
RUN pip install --upgrade pip
RUN pip install anvil-uplink
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy the current directory contents into the container at /usr/src/app
COPY ./uplink.py /usr/src/app
# Run the Python script when the container launches
CMD ["python", "./uplink.py"]
On another project (not open source, so can’t share), I’ve used a builder stage to construct the venv and then copied that into an alpine base for the final image. It worked a treat and I’d like to repeat the trick here.