The new (and improved) RCOS website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Dockerfile 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Dockerfile for Observatory-new
  2. # This takes advantage of multi-stage Docker builds to first compile and
  3. # bundle Observatory-new and then create a Docker image containing only
  4. # the necessary components.
  5. # Instructions on deploying this Docker image are in SETUP.md
  6. # --- Docker Build Stage 1 ---
  7. # Pulls from the MUSL builder since we are going to target Alpine Linux
  8. FROM ekidd/rust-musl-builder:nightly as builder
  9. # Copy in all the source files and switch to it
  10. COPY . /build/
  11. WORKDIR /build/
  12. # Fix permissions on source code.
  13. RUN sudo chown -R rust:rust /build/
  14. # Build the project in release mode
  15. RUN cargo build --release
  16. # Strip debug symbols out of binary
  17. RUN strip /build/target/x86_64-unknown-linux-musl/release/observatory
  18. # --- Docker Build Stage 2 ---
  19. # Use Alpine Linux for it's small footprint.
  20. FROM alpine
  21. # Set the workdir
  22. WORKDIR /
  23. USER root
  24. # Create the user's home folder and move to it
  25. RUN mkdir -p /home/observatory
  26. WORKDIR /home/observatory
  27. # Create a new user
  28. RUN adduser -h /home/observatory -S observatory
  29. # Create the folder that the database will be in
  30. RUN mkdir -p /var/lib/observatory
  31. # Change the owner of the database folder
  32. RUN chown -R observatory /var/lib/observatory/
  33. # Switch to the user
  34. USER observatory
  35. # Copy in the binary from the builder
  36. COPY --from=builder /build/target/x86_64-unknown-linux-musl/release/observatory .
  37. # Expose the HTTP port
  38. EXPOSE 8000
  39. # Run Observatory
  40. CMD ./observatory