Skip to content

Commit 03d0c6e

Browse files
committed
Fix Docker build and volume mounts
This commit corrects severe Dockerfile build issues by optimizing caching, resolving deprecated dependency repositories, and configuring the build to function offline. It also updates docker-compose.yml working directories.
1 parent 2f4fd75 commit 03d0c6e

File tree

4 files changed

+131
-41
lines changed

4 files changed

+131
-41
lines changed

Dockerfile

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
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.
82
FROM ruby:3.2.1
93

@@ -14,53 +8,40 @@ LABEL maintainer="Notebook.ai Contributors"
148
ARG RAILS_ENV=development
159
ENV 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
2412
RUN 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
4031
RUN 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.
6041
EXPOSE 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"]

Gemfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,7 @@ GEM
18861886
faye-websocket (0.11.3)
18871887
eventmachine (>= 0.12.0)
18881888
websocket-driver (>= 0.5.1)
1889+
ffi (1.17.2-aarch64-linux-gnu)
18891890
ffi (1.17.2-arm64-darwin)
18901891
ffi (1.17.2-x86_64-linux-gnu)
18911892
ffi-compiler (1.3.2)
@@ -1965,6 +1966,7 @@ GEM
19651966
letter_opener (~> 1.9)
19661967
railties (>= 6.1)
19671968
rexml
1969+
libv8-node (16.19.0.1-aarch64-linux)
19681970
libv8-node (16.19.0.1-arm64-darwin)
19691971
libv8-node (16.19.0.1-x86_64-linux)
19701972
listen (3.9.0)
@@ -2021,6 +2023,8 @@ GEM
20212023
net-protocol
20222024
netrc (0.11.0)
20232025
nio4r (2.7.4)
2026+
nokogiri (1.18.8-aarch64-linux-gnu)
2027+
racc (~> 1.4)
20242028
nokogiri (1.18.8-arm64-darwin)
20252029
racc (~> 1.4)
20262030
nokogiri (1.18.8-x86_64-linux-gnu)
@@ -2217,6 +2221,7 @@ GEM
22172221
actionpack (>= 6.1)
22182222
activesupport (>= 6.1)
22192223
sprockets (>= 3.0.0)
2224+
sqlite3 (1.7.3-aarch64-linux)
22202225
sqlite3 (1.7.3-arm64-darwin)
22212226
sqlite3 (1.7.3-x86_64-linux)
22222227
stackprof (0.2.27)
@@ -2278,6 +2283,7 @@ GEM
22782283
zeitwerk (2.7.2)
22792284

22802285
PLATFORMS
2286+
aarch64-linux
22812287
arm64-darwin-24
22822288
x86_64-linux
22832289

0 commit comments

Comments
 (0)