1- # HEADS UP!
2- # This Dockerfile is for DEVELOPMENT use only;
3- # it's in no way optimized for production and is largely maintained by
4- # the open source community for convenience. Installing the full stack
5- # manually is the preferred setup for Notebook.ai instances.
6-
71# The image to build from.
82FROM ruby:3.2.1
93
@@ -14,53 +8,40 @@ LABEL maintainer="Notebook.ai Contributors"
148ARG RAILS_ENV=development
159ENV RAILS_ENV=${RAILS_ENV}
1610
17- # Copy the current folder into the notebookai user's home directory.
18- COPY . /home/notebookai
19-
20- # Set the notebookai user's home directory as the working directory.
21- WORKDIR /home/notebookai
22-
2311# Create the notebookai user and group
2412RUN groupadd --system --gid 1000 notebookai && \
2513 useradd --system --home-dir /home/notebookai --gid notebookai --uid 1000 --shell /bin/bash notebookai
2614
2715# Install system dependencies
28- RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
16+ RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \
2917 apt-get update -qq && \
3018 apt-get install -y build-essential libpq-dev nodejs imagemagick libmagickwand-dev curl && \
3119 rm --recursive --force /var/lib/apt/lists/*
3220
33- # Install yarn
34- RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
35- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
36- apt-get update && \
37- apt-get install -y yarn
21+ # Install yarn via npm (avoids the deprecated apt-key approach)
22+ RUN npm install -g yarn
3823
39- # Install app dependencies, compile assets, and set up the database
24+ # Set the notebookai user's home directory as the working directory.
25+ WORKDIR /home/notebookai
26+
27+ # Copy dependencies first to maximize Docker layer caching
28+ COPY Gemfile Gemfile.lock package.json yarn.lock ./
29+
30+ # Install app dependencies
4031RUN bundle install && \
41- yarn install && \
42- if [ "$RAILS_ENV" = "development" ] ; then \
43- echo "Starting webpack-dev-server..." && \
44- bin/webpack-dev-server & \
45- else \
46- echo "Compiling webpack assets..." && \
47- rails webpacker:compile ; \
48- fi && \
49- rails db:setup && \
50- rake db:migrate && \
51- rm -f tmp/pids/server.pid
32+ yarn install
33+
34+ # Copy the remaining application files
35+ COPY . .
5236
53- # This image should expose the port 3000.
54- # This does not actually expose the port, you'll have to expose it yourself by
55- # using `-p 3000:3000/tcp` in Docker's CLI or `- "3000:3000"` in the in docker-compose.yml service's ports[].
56- # https://docs.docker.com/engine/reference/builder/#expose
57- # EXPOSE 3000/tcp
37+ # Adjust permissions on all copied files to match the system user
38+ RUN chown -R notebookai:notebookai /home/notebookai
5839
5940# This image should expose port 3000.
6041EXPOSE 3000/tcp
6142
62- # Finally, start the server using Puma!
63- CMD bundle exec puma -C config/puma.rb -e ${RAILS_ENV} -b tcp://0.0.0.0:3000
43+ # Run unprivileged
44+ USER notebookai
6445
65- # And run it with
66- # docker run --name nb-webserver -p 80:3000 -d notebookai
46+ # Start the server using Puma!
47+ CMD [ "bundle" , "exec" , "puma" , "-C" , "config/puma.rb" , "-e" , "development" , "-b" , "tcp://0.0.0.0:3000" ]
0 commit comments