FROM ubuntu:22.04 ARG USER_NAME="freedev" ENV DEBIAN_FRONTEND=noninteractive # upgrade and install basic tools RUN apt-get update && \ apt-get install -y --no-install-recommends \ sudo \ openssh-server \ jq \ vim \ git \ python3.10 \ python3-pip \ apt-transport-https \ ca-certificates \ curl \ gnupg \ lsb-release \ nginx \ && apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ mkdir /var/run/sshd # install Node.js and npm RUN curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - && \ apt-get install -y --no-install-recommends nodejs && \ rm -rf /var/lib/apt/lists/* # install Docker RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \ apt-get update && \ apt-get install -y --no-install-recommends docker-ce docker-ce-cli containerd.io && \ apt-get install docker-compose-plugin && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # install Docker Compose RUN curl -L "https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \ chmod +x /usr/local/bin/docker-compose # config SSH RUN sed -i 's/#ClientAliveInterval 0/ClientAliveInterval 60/' /etc/ssh/sshd_config && \ sed -i 's/#ClientAliveCountMax 3/ClientAliveCountMax 5/' /etc/ssh/sshd_config && \ sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config # expose SSH port EXPOSE 22 # copy entrypoint.sh COPY entrypoint.sh entrypoint_restore.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/entrypoint_restore.sh # set python3 as default python RUN ln -s /usr/bin/python3 /usr/bin/python # copy devbox files RUN mkdir -p /opt/devbox/ /mnt/docker_data/ /mnt/freeleaps/ COPY requirements.txt /opt/devbox/requirements.txt COPY acr_login.sh start_all_svc.sh stop_all_svc.sh init_devbox.sh start_backend.sh start_frontend.sh start_frontend_cn.sh gitea_data_backup.tar.gz .dev.env docker-compose.dev.yaml docker-compose.dev.arm64.yaml /opt/devbox/ RUN chmod +x /opt/devbox/*.sh && \ pip3 install --no-cache-dir --upgrade pip && \ pip3 install --no-cache-dir -r /opt/devbox/requirements.txt RUN useradd -m -s /bin/bash ${USER_NAME} && \ echo "${USER_NAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \ usermod -aG docker ${USER_NAME} && \ usermod --password $(echo "${USER_NAME}" | openssl passwd -1 -stdin) ${USER_NAME} && \ ln -s /opt/devbox /home/${USER_NAME}/devbox && \ ln -s /mnt/freeleaps /home/${USER_NAME}/freeleaps && \ chown -R "${USER_NAME}":"${USER_NAME}" /opt/devbox /mnt/freeleaps /home/${USER_NAME}/devbox /home/${USER_NAME}/freeleaps # install Azure CLI RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null && \ echo "deb [arch=$(dpkg --print-architecture)] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/azure-cli.list && \ apt-get update && \ apt-get install -y azure-cli # Copy SSH authorized keys and set permissions RUN mkdir -p /home/${USER_NAME}/.ssh COPY authorized_keys /home/${USER_NAME}/.ssh/authorized_keys RUN chown -R "${USER_NAME}":"${USER_NAME}" /home/${USER_NAME}/.ssh && \ chmod 700 /home/${USER_NAME}/.ssh && \ chmod 600 /home/${USER_NAME}/.ssh/authorized_keys RUN npm install -g @apollo/client @popperjs/core @vue/apollo-composable axios bootstrap buffer echarts graphql graphql-tag pdfjs-dist pinia vue vue-echarts vue-i18n vue-router vuex @rushstack/eslint-patch @vitejs/plugin-vue @vue/eslint-config-prettier eslint eslint-plugin-vue fast-glob prettier sass sass-loader vite vite-plugin-svg-icons webpack || true # start CMD ["/usr/local/bin/entrypoint.sh"]