Skip to content

Commit a20217b

Browse files
author
Andrew Brown
committed
update the dockerfile to actually work
1 parent c7053c8 commit a20217b

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

Dockerfile

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,42 @@ FROM ruby:3.2.1
1010
# Properties/labels for the image.
1111
LABEL maintainer="Notebook.ai Contributors"
1212

13+
# Development ENV by default, but overridable with RAILS_ENV
14+
ARG RAILS_ENV=development
15+
ENV RAILS_ENV=${RAILS_ENV}
16+
1317
# Copy the current folder into the notebookai user's home directory.
1418
COPY . /home/notebookai
1519

1620
# Set the notebookai user's home directory as the working directory.
1721
WORKDIR /home/notebookai
1822

19-
# Prep the image for runtime, this should all be done in one command
20-
# to minimize image layers.
21-
# See: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#minimize-the-number-of-layers
23+
# Create the notebookai user and group
2224
RUN groupadd --system --gid 1000 notebookai && \
23-
useradd --system --home-dir /home/notebookai --gid notebookai --uid 1000 --shell /bin/bash notebookai && \
25+
useradd --system --home-dir /home/notebookai --gid notebookai --uid 1000 --shell /bin/bash notebookai
26+
27+
# Install system dependencies
28+
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
2429
apt-get update -qq && \
25-
apt-get install -y build-essential libpq-dev nodejs imagemagick libmagickwand-dev && \
26-
rm --recursive --force /var/lib/apt/lists/* && \
27-
bundle install && \
30+
apt-get install -y build-essential libpq-dev nodejs imagemagick libmagickwand-dev curl && \
31+
rm --recursive --force /var/lib/apt/lists/*
32+
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
38+
39+
# Install app dependencies, compile assets, and set up the database
40+
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 && \
2849
rails db:setup
2950

3051
# This image should expose the port 3000.

0 commit comments

Comments
 (0)