skip to Main Content

So i have this simple code to run.

import streamlit as st 

st.title("hellobored")

I create a docker image of this code with a simple earthfile with the command earthly +all

VERSION 0.8
streamlit: 
    FROM python:3.11-slim
    WORKDIR /src/app
    RUN apt-get update && apt-get install -y curl
    RUN python -m pip install --upgrade pip
    RUN pip install streamlit
    COPY ./hellobored.py /src/app/hellobored.py
    RUN ls
    EXPOSE 8501
    ENTRYPOINT ["streamlit", "run", "/src/app/hellobored.py", "--server.port=8501"]
    SAVE IMAGE hellobored

all: 
    BUILD +streamlit

I have a docker compose that look like that

version: '3.8'
services:   
  streamlit:
    image: hellobored
    ports:
      - "8501:8501"
    develop: 
      watch:
      - path: ./
        action: rebuild
      - path: ./
        target: /src/app/
        action: sync 

I already tried using rebuil or sync separately but both doesn’t seem to work
I use docker compose up -d and docker compose watch to see the watch related problem and received this error for the rebuid.

[+] Running 1/0manualy
✔ Container hellobored-streamlit-1 Running 0.0s
can’t watch service "streamlit" with action rebuild without a build context

And this error for the sync

[+] Running 1/0
✔ Container hellobored-streamlit-1 Running 0.0s
none of the selected services is configured for watch, consider setting an ‘develop’ section

I can’t find the way to give docker compose a buid context for earthly on the net so im asking here.
For note i need the build to be done by earthly because the image I create are 10Go and earthly can compile them in seconds. I need watch because it would be really long to rebuild and reload manually the image after every changes.

2

Answers


  1. Chosen as BEST ANSWER

    I got the answer you just need to add a build context! Why? No idea. It work so im happy .

    version: '3.8'
    services:   
      streamlit:
        image: hellobored
        build:
          context: .
        ports:
          - "8501:8501"
        develop: 
          watch:
          - path: ./
            target: /src/app/
            action: sync 
    

  2. In your initial setup, the docker-compose-watch command failed because there was no build context specified. Docker Compose requires a build context to track changes and trigger rebuilds. Without a build context, the watch command cannot determine which files to monitor for changes.

    build:
      context: .
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search