Skip to content

Commit

Permalink
update the dockerfile to actually work
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Brown committed May 1, 2023
1 parent c7053c8 commit a20217b
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,42 @@ FROM ruby:3.2.1
# Properties/labels for the image.
LABEL maintainer="Notebook.ai Contributors"

# Development ENV by default, but overridable with RAILS_ENV
ARG RAILS_ENV=development
ENV RAILS_ENV=${RAILS_ENV}

# Copy the current folder into the notebookai user's home directory.
COPY . /home/notebookai

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

# Prep the image for runtime, this should all be done in one command
# to minimize image layers.
# See: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#minimize-the-number-of-layers
# Create the notebookai user and group
RUN groupadd --system --gid 1000 notebookai && \
useradd --system --home-dir /home/notebookai --gid notebookai --uid 1000 --shell /bin/bash notebookai && \
useradd --system --home-dir /home/notebookai --gid notebookai --uid 1000 --shell /bin/bash notebookai

# Install system dependencies
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
apt-get update -qq && \
apt-get install -y build-essential libpq-dev nodejs imagemagick libmagickwand-dev && \
rm --recursive --force /var/lib/apt/lists/* && \
bundle install && \
apt-get install -y build-essential libpq-dev nodejs imagemagick libmagickwand-dev curl && \
rm --recursive --force /var/lib/apt/lists/*

# Install yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y yarn

# Install app dependencies, compile assets, and set up the database
RUN bundle install && \
yarn install && \
if [ "$RAILS_ENV" = "development" ] ; then \
echo "Starting webpack-dev-server..." && \
bin/webpack-dev-server & \
else \
echo "Compiling webpack assets..." && \
rails webpacker:compile ; \
fi && \
rails db:setup

# This image should expose the port 3000.
Expand Down

0 comments on commit a20217b

Please sign in to comment.