diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..0da30ab5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +# Don't include any of these files in the Dockerfile build context. +# This will improve build performance and reduce the final image size. +# See: https://docs.docker.com/engine/reference/builder/#dockerignore-file +.git/ +.github/ +.coveralls.yml +.dockerignore +.editorconfig +.gitignore +.travis.yml +.rubocop.yml +CHANGELOG.md +docker-compose.yml +log/ +test/ diff --git a/.ruby-version b/.ruby-version index a6e69306..338a5b5d 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1,2 +1 @@ 2.6.6 - diff --git a/Dockerfile b/Dockerfile index 36b7b7d4..e4c9c96d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,32 @@ +# HEADS UP! +# This Dockerfile is for DEVELOPMENT use only; +# it's in no way optimized for production. + +# The image to build from. FROM ruby:2.6.3 -RUN apt-get update -qq && \ + +# Properties/labels for the image. +LABEL maintainer="Notebook.ai Contributors" + +# 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 +RUN groupadd --system --gid 1000 notebookai && \ + useradd --system --home-dir /home/notebookai --gid notebookai --uid 1000 --shell /bin/bash notebookai && \ + apt-get update -qq && \ apt-get install -y build-essential libpq-dev nodejs imagemagick libmagickwand-dev && \ - mkdir /notebook-ai -COPY . /notebook-ai -WORKDIR /notebook-ai -RUN bundle install -RUN rails db:setup + rm --recursive --force /var/lib/apt/lists/* && \ + bundle install && \ + rails db:setup + +# This image should expose the port 3000. +# This does not actually expose the port, you'll have to expose it yourself by +# using `-p 3000:3000/tcp` in Docker's CLI or `- "3000:3000"` in the in docker-compose.yml service's ports[]. +# https://docs.docker.com/engine/reference/builder/#expose +EXPOSE 3000/tcp diff --git a/docker-compose.yml b/docker-compose.yml index 577193d9..3eb3943e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,9 @@ -version: '2' +version: "3.8" services: - web: - build: . - command: sh -c "rake db:migrate && rm -f tmp/pids/server.pid && exec bundle exec rails server -b '0.0.0.0'" - volumes: - - .:/notebook-ai - ports: - - "3000:3000" + notebookai: + build: . + ports: + - "3000:3000/tcp" + command: sh -c "rake db:migrate && rm -f tmp/pids/server.pid && exec bundle exec rails server -b 0.0.0.0" + volumes: + - "./:/notebook-ai"