Merge pull request #769 from SethiPandi/docker-improvement

Improve Development Docker Build
This commit is contained in:
Andrew Brown 2020-10-07 00:18:47 -07:00 committed by GitHub
commit 276b0e7ae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 15 deletions

15
.dockerignore Normal file
View File

@ -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/

View File

@ -1,2 +1 @@
2.6.6

View File

@ -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

View File

@ -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"