Jimmy Jensen
08/12/2022, 6:04 PMrex
08/12/2022, 7:46 PMJimmy Jensen
08/12/2022, 7:49 PMclaire
08/12/2022, 7:50 PMdocker_example_user_code
service (code here) I added a bind mount that maps my dagster source code directory to the working directory listed in the Dockerfile_user_code
(file here). So the service snippet now looks like:
docker_example_user_code:
build:
context: .
dockerfile: ./Dockerfile_user_code
container_name: docker_example_user_code
image: docker_example_user_code_image
restart: always
environment:
DAGSTER_POSTGRES_USER: "postgres_user"
DAGSTER_POSTGRES_PASSWORD: "postgres_password"
DAGSTER_POSTGRES_DB: "postgres_db"
DAGSTER_CURRENT_IMAGE: "docker_example_user_code_image"
volumes: # added this section here
- type: bind
source: /Users/claire/Desktop/deploy_docker/src
target: /opt/dagster/app/
networks:
- docker_example_network
My dagster code is located in the /Users/claire/Desktop/deploy_docker/src
directory. The Dockerfile_user_code file then has to be edited to no longer copy the code into the working directory (So commented out COPY repo.py /opt/dagster/app
)
Then, in the dagster.yaml
file, I added an additional volume to the run_launcher
snippet to allow the mounted code to be accessible to the run launcher:
run_launcher:
module: dagster_docker
class: DockerRunLauncher
config:
env_vars:
- DAGSTER_POSTGRES_USER
- DAGSTER_POSTGRES_PASSWORD
- DAGSTER_POSTGRES_DB
network: docker_example_network
container_kwargs:
volumes: # Make docker client accessible to any launched containers as well
- /var/run/docker.sock:/var/run/docker.sock
- /tmp/io_manager_storage:/tmp/io_manager_storage
- /Users/claire/Desktop/deploy_docker/src:/opt/dagster/app # This line here
After that, I was able to view dagit locally by running docker-compose up. Reloading my code via the instance status page picked up on new code changesJimmy Jensen
08/12/2022, 8:07 PM/c
in front of the source path since I am on Windows. And I also removed /src
at the end of the source path.
I suppose you have moved the repo.py
file in the src
folder?claire
08/12/2022, 8:07 PM