LisaMegaWatts Claude Opus 4.6 commited on
Commit
f518001
·
1 Parent(s): 07b19c7

Fix package loading: use shared Julia depot and single project path

Browse files

Packages were installed to /app as root with depot at /root/.julia,
but the server ran as uid 1000 who couldn't access the root depot.
Now uses JULIA_DEPOT_PATH=/opt/julia-depot (shared) and a single
project path at /home/user/app for both install and runtime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. Dockerfile +16 -14
Dockerfile CHANGED
@@ -3,25 +3,27 @@ FROM julia:1.10-bookworm
3
  # HuggingFace Spaces requires user ID 1000
4
  RUN useradd -m -u 1000 user
5
 
6
- # Install Julia packages (cached layer)
7
- WORKDIR /app
8
- COPY Project.toml /app/
9
- RUN julia --project=/app -e 'using Pkg; Pkg.add(["HTTP", "JSON3"]); Pkg.precompile()'
10
- RUN julia --project=/app -e 'using HTTP, JSON3; println("Precompile done")'
11
 
12
- # Switch to non-root user
13
- USER user
14
- ENV HOME=/home/user
15
- WORKDIR /home/user/app
16
-
17
- # Copy application code
18
  COPY --chown=user model.jl /home/user/app/
19
  COPY --chown=user checkpoint.jl /home/user/app/
20
  COPY --chown=user server.jl /home/user/app/
21
- COPY --chown=user Project.toml /home/user/app/
22
  COPY --chown=user checkpoints/ /home/user/app/checkpoints/
23
 
24
- # Default port for HuggingFace Spaces (override with PORT env var)
 
 
 
 
 
 
 
 
 
25
  EXPOSE 7860
26
 
27
- CMD ["julia", "--project=/app", "/home/user/app/server.jl"]
 
3
  # HuggingFace Spaces requires user ID 1000
4
  RUN useradd -m -u 1000 user
5
 
6
+ # Set up shared Julia depot so packages are accessible to all users
7
+ ENV JULIA_DEPOT_PATH=/opt/julia-depot
8
+ RUN mkdir -p /opt/julia-depot && chmod 777 /opt/julia-depot
 
 
9
 
10
+ # Copy all application code into /home/user/app
11
+ COPY --chown=user Project.toml /home/user/app/
 
 
 
 
12
  COPY --chown=user model.jl /home/user/app/
13
  COPY --chown=user checkpoint.jl /home/user/app/
14
  COPY --chown=user server.jl /home/user/app/
 
15
  COPY --chown=user checkpoints/ /home/user/app/checkpoints/
16
 
17
+ # Install and precompile Julia packages
18
+ RUN julia --project=/home/user/app -e 'using Pkg; Pkg.add(["HTTP", "JSON3"]); Pkg.precompile()'
19
+ RUN julia --project=/home/user/app -e 'using HTTP, JSON3; println("Precompile done")'
20
+
21
+ # Switch to non-root user
22
+ USER user
23
+ ENV HOME=/home/user
24
+ WORKDIR /home/user/app
25
+
26
+ # Default port for HuggingFace Spaces
27
  EXPOSE 7860
28
 
29
+ CMD ["julia", "--project=/home/user/app", "/home/user/app/server.jl"]