Dockerfile 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # First build the container:
  2. # docker build -t harvey:Dockerfile .
  3. # (or:
  4. # docker build --progress=plain -t harvey:Dockerfile .
  5. # if you want to see the output from commands (useful for debugging build))
  6. #
  7. # Now run container to build.
  8. # If you want to build from the repo (i.e. for CI), run:
  9. # docker run --rm -it --cap-add SYS_ADMIN --privileged harvey:Dockerfile
  10. # If you want to build from a local folder (e.g. the current directoy), run:
  11. # docker run --rm -it --mount type=bind,source="$(pwd)"/..,target=/usr/local/harvey_local,readonly --cap-add SYS_ADMIN --privileged harvey:Dockerfile
  12. # TODO mahjonng doesn't build becuase of problems with cpp - fix cpp!
  13. FROM ubuntu:21.10
  14. RUN apt-get -y update
  15. RUN apt-get -y upgrade
  16. RUN apt-get install -y build-essential git sudo
  17. ENV HARVEY=/usr/local/harvey
  18. ENV HARVEY_LINUX_BIN=/usr/local/harvey_linux/bin
  19. RUN mkdir -p $HARVEY_LINUX_BIN
  20. ########################################################################
  21. # Only use layer cache if the git repo hasn't changed. This ensures we
  22. # always have the latest code, but make use of the cache where possible.
  23. ARG NINEFANS_OWNER=9fans
  24. ARG NINEFANS_REPO=plan9port
  25. ARG NINEFANS_BRANCH=master
  26. ADD https://api.github.com/repos/$NINEFANS_OWNER/$NINEFANS_REPO/git/refs/heads/$NINEFANS_BRANCH version.json
  27. RUN cd /usr/local \
  28. && git clone -b $NINEFANS_BRANCH https://github.com/$NINEFANS_OWNER/$NINEFANS_REPO.git \
  29. && cd plan9port \
  30. && ./INSTALL
  31. ENV PLAN9=/usr/local/plan9port
  32. ENV PATH="${PATH}:${PLAN9}/bin"
  33. # To make rc scripts run
  34. RUN cp ${PLAN9}/bin/rc /bin/rc
  35. ########################################################################
  36. # Build ar from 9-cc
  37. # Do this early since it's less likely to change than the harvey repo,
  38. # allowing us to use the cached layers.
  39. ARG NINECC_OWNER=0intro
  40. ARG NINECC_REPO=9-cc
  41. ARG NINECC_BRANCH=master
  42. ADD https://api.github.com/repos/$NINECC_OWNER/$NINECC_REPO/git/refs/heads/$NINECC_BRANCH version.json
  43. RUN cd /usr/local \
  44. && git clone -b $NINECC_BRANCH https://github.com/$NINECC_OWNER/$NINECC_REPO.git
  45. ENV NINECC=/usr/local/9-cc
  46. WORKDIR $NINECC
  47. COPY 9-cc.patch $NINECC/9-cc.patch
  48. RUN git apply $NINECC/9-cc.patch
  49. RUN if [ `uname -p` = "aarch64" ]; then \
  50. mkdir -p Linux/arm/bin; \
  51. mkdir -p Linux/arm/include; \
  52. mkdir -p Linux/arm/lib; \
  53. else \
  54. mkdir -p Linux/amd64/bin; \
  55. mkdir -p Linux/amd64/include; \
  56. mkdir -p Linux/amd64/lib; \
  57. fi
  58. # Hack up 9-cc to build ar for amd64 (or arm)
  59. RUN ./configure && . ./env
  60. RUN if [ `uname -p` = "aarch64" ]; then \
  61. cp Linux/amd64/include/lib9.h Linux/arm/include/lib9.h; \
  62. cp Linux/amd64/include/fpuctl.h Linux/arm/include/fpuctl.h; \
  63. sed -i 's/arm-gcc/gcc/' mkfiles/mkfile-Linux-arm; \
  64. fi
  65. RUN mk
  66. RUN cp ${NINECC}/src/cmd/iar/o.out $HARVEY_LINUX_BIN/ar
  67. #TEMP!
  68. COPY BUILD_IN_DOCKER /usr/local/
  69. ENTRYPOINT ["bash", "/usr/local/BUILD_IN_DOCKER"]