|
| 1 | +FROM ubuntu:22.04 |
| 2 | + |
| 3 | +ARG NODE_VERSION=20 |
| 4 | +ARG POSTGRES_VERSION=15 |
| 5 | +ARG USER=coder |
| 6 | + |
| 7 | +WORKDIR $WORKDIR |
| 8 | + |
| 9 | +ENV DEBIAN_FRONTEND noninteractive |
| 10 | +ENV TZ=UTC |
| 11 | + |
| 12 | +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone |
| 13 | + |
| 14 | +RUN apt-get update \ |
| 15 | + && mkdir -p /etc/apt/keyrings \ |
| 16 | + && apt-get install -y gnupg gosu curl ca-certificates zip unzip supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin fswatch ffmpeg \ |
| 17 | + build-essential htop jq locales man python3 python3-pip software-properties-common sudo systemd systemd-sysv wget rsync nano phpmyadmin apache2 \ |
| 18 | + && add-apt-repository ppa:git-core/ppa \ |
| 19 | + && apt-get install --yes git \ |
| 20 | + && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null \ |
| 21 | + && echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ |
| 22 | + && apt-get update \ |
| 23 | + && apt-get install -y php8.3-cli php8.3-dev \ |
| 24 | + php8.3-pgsql php8.3-sqlite3 php8.3-gd \ |
| 25 | + php8.3-curl \ |
| 26 | + php8.3-imap php8.3-mysql php8.3-mbstring \ |
| 27 | + php8.3-xml php8.3-zip php8.3-bcmath php8.3-soap \ |
| 28 | + php8.3-intl php8.3-readline \ |
| 29 | + php8.3-ldap \ |
| 30 | + php8.3-msgpack php8.3-igbinary php8.3-redis php8.3-swoole \ |
| 31 | + php8.3-memcached php8.3-pcov php8.3-imagick php8.3-xdebug \ |
| 32 | + php8.3-fpm libapache2-mod-php8.3 \ |
| 33 | + && curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer \ |
| 34 | + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ |
| 35 | + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \ |
| 36 | + && apt-get update \ |
| 37 | + && apt-get install -y nodejs \ |
| 38 | + && npm install -g npm \ |
| 39 | + && npm install -g pnpm \ |
| 40 | + && npm install -g bun \ |
| 41 | + && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /etc/apt/keyrings/yarn.gpg >/dev/null \ |
| 42 | + && echo "deb [signed-by=/etc/apt/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \ |
| 43 | + && curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/keyrings/pgdg.gpg >/dev/null \ |
| 44 | + && echo "deb [signed-by=/etc/apt/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ |
| 45 | + && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \ |
| 46 | + && echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" > /etc/apt/sources.list.d/docker.list \ |
| 47 | + && curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg \ |
| 48 | + && echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list \ |
| 49 | + && apt-get update \ |
| 50 | + && apt-get install -y yarn \ |
| 51 | + && apt-get install -y mysql-server mysql-client \ |
| 52 | + && apt-get install -y postgresql-$POSTGRES_VERSION \ |
| 53 | + && apt-get install -y containerd.io docker-ce docker-ce-cli docker-buildx-plugin docker-compose-plugin \ |
| 54 | + && apt-get install -y redis |
| 55 | + |
| 56 | +RUN apt-get -y autoremove \ |
| 57 | + && apt-get clean \ |
| 58 | + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |
| 59 | + |
| 60 | +RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ |
| 61 | + dpkg-reconfigure --frontend=noninteractive locales && \ |
| 62 | + update-locale LANG=en_US.UTF-8 |
| 63 | + |
| 64 | +ENV LANG en_US.UTF-8 |
| 65 | + |
| 66 | +RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.3 |
| 67 | + |
| 68 | +RUN ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose |
| 69 | + |
| 70 | +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf |
| 71 | +COPY php.ini /etc/php/8.3/cli/conf.d/99-sail.ini |
| 72 | + |
| 73 | +# Setting up phpmyadmin |
| 74 | +RUN mkdir -p /ssl |
| 75 | +RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \ |
| 76 | + -keyout /ssl/apache.key -out /ssl/apache.crt \ |
| 77 | + -subj "/C=US/ST=State/L=City/O=Organization/OU=Organizational Unit/CN=localhost" |
| 78 | + |
| 79 | +RUN a2enmod ssl |
| 80 | +RUN sed -ri -e 's,80,4443,' /etc/apache2/sites-available/000-default.conf |
| 81 | +RUN sed -i -e '/^<\/VirtualHost>/i SSLEngine on' /etc/apache2/sites-available/000-default.conf |
| 82 | +RUN sed -i -e '/^<\/VirtualHost>/i SSLCertificateFile /ssl/apache.crt' /etc/apache2/sites-available/000-default.conf |
| 83 | +RUN sed -i -e '/^<\/VirtualHost>/i SSLCertificateKeyFile /ssl/apache.key' /etc/apache2/sites-available/000-default.conf |
| 84 | + |
| 85 | +RUN sed -ri -e 's,80,8080,' /etc/apache2/ports.conf |
| 86 | +RUN sed -ri -e 's,443,4443,' /etc/apache2/ports.conf |
| 87 | + |
| 88 | +# RUN echo "\$cfg['ForceSSL'] = 'true';" >> /etc/phpmyadmin/config.inc.php |
| 89 | +# RUN sed -i "/\$cfg\['Servers'\]\[\$i\]\['auth_type'\] = 'cookie';/c\\\$cfg\['Servers'\]\[\$i\]\['auth_type'\] = 'http';" /etc/phpmyadmin/config.inc.php |
| 90 | +RUN ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf |
| 91 | +RUN a2enconf phpmyadmin.conf |
| 92 | +RUN a2enconf php8.3-fpm |
| 93 | +# RUN sed -i "/VirtualHost \*:80/c\\<VirtualHost \*:8080\>" /etc/apache2/sites-enabled/000-default.conf |
| 94 | +# RUN sed -i "/Listen 80/c\Listen 8080" /etc/apache2/ports.conf |
| 95 | +RUN apachectl configtest |
| 96 | + |
| 97 | +COPY start.sh /usr/local/bin/start.sh |
| 98 | +RUN chmod +x /usr/local/bin/start.sh |
| 99 | +RUN sed -i -e 's/\r$//' /usr/local/bin/start.sh |
| 100 | + |
| 101 | +RUN useradd --groups sudo --create-home --shell /bin/bash $USER \ |
| 102 | + && echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \ |
| 103 | + && chmod 0440 /etc/sudoers.d/${USER} |
| 104 | + |
| 105 | +USER ${USER} |
0 commit comments