coder-templates/docker-images/backend-node.Dockerfile
2023-09-26 15:03:01 -04:00

56 lines
No EOL
1.9 KiB
Docker

# Start from base image (built on Docker host)
FROM git.kakio.us/kakious/coder-base:latest
# Install everything as root
USER root
# Install Node
RUN curl -sL https://deb.nodesource.com/setup_19.x | bash -
RUN DEBIAN_FRONTEND="noninteractive" apt-get update -y && \
apt-get install -y nodejs
# Install Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN DEBIAN_FRONTEND="noninteractive" apt-get update && apt-get install -y yarn
# Create the persistent data folder
RUN mkdir -p /data
# Install MySQL
RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-server
# Move the data folder to the persistent data folder and grant mysql access to it
RUN mv /var/lib/mysql /data/mysql
RUN echo "datadir = /data/mysql" >> /etc/mysql/mysql.conf.d/mysqld.cnf
RUN usermod -a -G coder mysql
# Create a symbolic link to the persistent data folder just in case
RUN ln -s /data/mysql /var/lib/mysql
# Install Redis
RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y redis-server
# Install the latest redisjson
RUN wget https://redismodules.s3.amazonaws.com/rejson/rejson.Linux-ubuntu20.04-x86_64.2.4.5.zip
RUN unzip rejson.Linux-ubuntu20.04-x86_64.2.4.5.zip
RUN mkdir -p /usr/lib/redis/modules
RUN cp rejson.so /usr/lib/redis/modules/rejson.so
RUN rm rejson.Linux-ubuntu20.04-x86_64.2.4.5.zip && rm rejson.so
# Update the redis config to include loadmodule
RUN echo "loadmodule /usr/lib/redis/modules/rejson.so" >> /etc/redis/redis.conf
# Install the latest rabbitmq
RUN apt install -y rabbitmq-server
RUN ln -s /data/rabbitmq /var/lib/rabbitmq
RUN sudo usermod -d /data/mysql/ mysql
# Make sure the services are started on the start of the container
CMD service mysql start && service redis-server start && service rabbitmq-server start && /usr/bin/code-server --bind-addr
# Set back to coder user
USER coder