Dockerfile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # from latest debian:stable on 2018-08-10 approximately at 15:00
  2. # FROM debian@sha256:272b4877ca42d22addd178b8d546fb78546fee40e2dae6b9316d21f048d2ecec
  3. FROM debian@sha256:52af198afd8c264f1035206ca66a5c48e602afb32dc912ebf9e9478134601ec4
  4. MAINTAINER zelphirkaltstahl@gmail.com
  5. ENV META_IMAGE_NAME="zwiki"
  6. ENV META_COURSE_VERSION="0.0.1"
  7. ###################
  8. # SYSTEM PACKAGES #
  9. ###################
  10. USER root
  11. RUN REPO=http://cdn-fastly.deb.debian.org \
  12. && echo "deb $REPO/debian jessie main\ndeb $REPO/debian-security jessie/updates main" > /etc/apt/sources.list \
  13. && apt-get update && apt-get --yes --quiet dist-upgrade \
  14. && apt-get install --yes --quiet --no-install-recommends \
  15. libc6-dev libc-dev \
  16. gcc g++ \
  17. dpkg-dev \
  18. make \
  19. openssl \
  20. wget \
  21. curl \
  22. bzip2 \
  23. ca-certificates \
  24. sudo \
  25. locales \
  26. build-essential \
  27. python-dev \
  28. libsm6 \
  29. && apt-get clean \
  30. && rm -rf /var/lib/apt/lists/*
  31. ############
  32. # ENV VARS #
  33. ############
  34. ARG DEBIAN_FRONTEND="noninteractive"
  35. ENV SHELL /bin/bash
  36. # user and group
  37. ENV NON_PRIVILEGED_USER="zwiki"
  38. ARG NON_PRIVILEGED_USER_PASSWORD="some password here"
  39. ENV NON_PRIVILEGED_USER_GROUP="zwiki"
  40. #################
  41. # ADDING A USER #
  42. #################
  43. # For more info please check useradd --help or man useradd.
  44. ENV HOME="/home/${NON_PRIVILEGED_USER}"
  45. RUN groupadd -r $NON_PRIVILEGED_USER_GROUP -g 1000 \
  46. && useradd \
  47. --uid 1000 \
  48. --system \
  49. --gid $NON_PRIVILEGED_USER_GROUP \
  50. --create-home \
  51. --home-dir "${HOME}" \
  52. --shell /bin/bash \
  53. --comment "non-privileged user" \
  54. $NON_PRIVILEGED_USER \
  55. && chmod 755 "${HOME}" \
  56. && echo "${NON_PRIVILEGED_USER}:${NON_PRIVILEGED_USER_PASSWORD}" | chpasswd
  57. # setup curl
  58. RUN echo "cacert=/etc/ssl/certs/ca-certificates.crt" > "${HOME}/.curlrc" # do we really need this? (for wget?)
  59. ##############
  60. # SET LOCALE #
  61. ##############
  62. RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
  63. echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
  64. dpkg-reconfigure --frontend=noninteractive locales && \
  65. update-locale LANG=en_US.UTF-8
  66. ENV LANG en_US.UTF-8
  67. ENV LANGUAGE en_US:en
  68. ENV LC_ALL en_US.UTF-8
  69. #################
  70. # INSTALL CONDA #
  71. #################
  72. USER $NON_PRIVILEGED_USER
  73. ARG CONDA_DIR="${HOME}/anaconda"
  74. ARG MINICONDA_VERSION="4.5.4"
  75. ARG MINICONDA_SHA256SUM="80ecc86f8c2f131c5170e43df489514f80e3971dd105c075935470bbf2476dea"
  76. ARG MINICONDA_DOWNLOAD_URL="https://repo.continuum.io/miniconda/Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh"
  77. ARG MINICONDA_DOWNLOAD_FILENAME="miniconda.sh"
  78. ARG CONDA_DIR="${HOME}/miniconda"
  79. # add conda to path
  80. ENV PATH $CONDA_DIR/bin:$PATH
  81. WORKDIR "${HOME}"
  82. RUN mkdir --parents $CONDA_DIR\
  83. && wget --quiet "${MINICONDA_DOWNLOAD_URL}" --output-document="${MINICONDA_DOWNLOAD_FILENAME}"\
  84. && echo "${MINICONDA_SHA256SUM}" "${MINICONDA_DOWNLOAD_FILENAME}" | sha256sum -c -\
  85. && /bin/bash $MINICONDA_DOWNLOAD_FILENAME -f -b -p $CONDA_DIR \
  86. && rm $MINICONDA_DOWNLOAD_FILENAME \
  87. && conda update -n base conda \
  88. && $CONDA_DIR/bin/conda config --system --add channels conda-forge \
  89. && $CONDA_DIR/bin/conda config --system --set auto_update_conda false \
  90. && conda clean -tips --yes
  91. ##################
  92. # CONDA PACKAGES #
  93. ##################
  94. USER $NON_PRIVILEGED_USER
  95. RUN conda install --yes --quiet -c conda-forge \
  96. gunicorn=19.7.1 \
  97. falcon=1.4.1
  98. RUN conda clean -tips --yes
  99. ################
  100. # PIP PACKAGES #
  101. ################
  102. # (stuff which is not on conda)
  103. USER $NON_PRIVILEGED_USER
  104. ###############
  105. # COPY SERVER #
  106. ###############
  107. USER root
  108. COPY app/ "${HOME}/app"
  109. COPY start_zwiki.sh "${HOME}/start_zwiki.sh"
  110. RUN chown $NON_PRIVILEGED_USER:$NON_PRIVILEGED_USER_GROUP --recursive "${HOME}/app"
  111. ############
  112. # FINALIZE #
  113. ############
  114. # PORT
  115. EXPOSE 5000
  116. # INITIAL DIRECTORY
  117. WORKDIR /home/$NON_PRIVILEGED_USER/work
  118. # switch back to jovyan to avoid accidental container runs as root
  119. USER $NON_PRIVILEGED_USER
  120. # configure container startup
  121. CMD ["/bin/sh", "/home/tester/start_zwiki.sh"]