From 378afdc4734089ac493027e4d9bf292c0ccac999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Wed, 8 Jul 2020 09:08:39 +0200 Subject: [PATCH] fix: building image with extensions and batch manager --- .env.sample | 11 +++++++++++ Dockerfile | 40 ++++++++++++++-------------------------- docker/entrypoint | 19 ------------------- docker/entrypoint.sh | 17 +++++++++++++++++ 4 files changed, 42 insertions(+), 45 deletions(-) create mode 100644 .env.sample delete mode 100755 docker/entrypoint create mode 100755 docker/entrypoint.sh diff --git a/.env.sample b/.env.sample new file mode 100644 index 00000000000..5a23522fb06 --- /dev/null +++ b/.env.sample @@ -0,0 +1,11 @@ +RAILS_ENV=development +PORT=3000 +WEB_CONCURRENCY=0 +RAILS_LOG_TO_STDOUT=true +RAILS_SERVE_STATIC_FILES=true +SECRET_KEY_BASE=test +APP_HOST=http://localhost:3000 + +EXTENSIONS_MANAGER_LOCATION=extensions/extensions-manager/dist/index.html +BATCH_MANAGER_LOCATION=extensions/batch-manager/dist/index.min.html +SF_DEFAULT_SERVER=http://localhost:3001 diff --git a/Dockerfile b/Dockerfile index 5b12e1d40e6..b13808ea272 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,43 +1,31 @@ -### -# Build with 'docker build -t standard_notes_web.img .' -# Run with 'docker run -d -p 127.0.0.1:3000:3000 --name standard_notes_web --restart always standard_notes_web.img' -# If you need shell access, run 'docker exec -it standard_notes_web /bin/sh' -# Access from http://localhost:3000/ -# Set up Nginx to terminate SSL with LetsEncrypt and proxy_pass to http://localhost:3000/ -### - FROM ruby:2.7.1-alpine RUN apk add --update --no-cache \ alpine-sdk \ nodejs \ + python2 \ + git \ nodejs-npm \ tzdata WORKDIR /app/ +COPY package.json package-lock.json Gemfile Gemfile.lock /app/ + +COPY vendor /app/vendor + +RUN npm ci + +RUN gem install bundler && bundle install + COPY . /app/ -### -# FOR PRODUCTION USE: -# -# If you need the app to continue listening on HTTP instead of HTTPS -# (like terminating SSL on upstream server, i.e. Nginx proxy_pass to HTTP), -# you will need to set 'config.force_ssl = false' in 'config/environments/production.rb'. -# -# Uncomment SECRET_KEY_BASE, RAILS_ENV, and [optionally] RAILS_SERVE_STATIC_FILES for production: -# ENV SECRET_KEY_BASE=[VALUE OF `bundle exec rake secret`] -# -# ENV RAILS_ENV=production -# -# ENV RAILS_SERVE_STATIC_FILES=true -# Leave RAILS_SERVE_STATIC_FILES commented if Nginx/Apache will serve static files instead of rails. -### - -RUN npm run build +RUN bundle exec rails assets:precompile + +RUN npm run bundle EXPOSE 3000 -ENTRYPOINT [ "./docker/entrypoint" ] +ENTRYPOINT [ "./docker/entrypoint.sh" ] CMD [ "start" ] diff --git a/docker/entrypoint b/docker/entrypoint deleted file mode 100755 index d067f7e44eb..00000000000 --- a/docker/entrypoint +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env sh -# $0 is a script name, -# $1, $2, $3 etc are passed arguments -# $1 is our command -CMD=$1 - -case "$CMD" in - 'start' ) - echo `pwd` - rm -f /app/tmp/pids/server.pid - bundle exec rails s -b 0.0.0.0 - ;; - - * ) - # Run custom command. Thanks to this line we can still use - # "docker run our_image /bin/sh" and it will work - exec "$@" - ;; -esac diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 00000000000..637b76ccb5a --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -e + +case "$1" in + 'start' ) + echo "Prestart Step 1/1 - Removing server lock" + rm -f /app/tmp/pids/server.pid + echo "Starting Server..." + bundle exec rails s -b 0.0.0.0 + ;; + + * ) + echo "Unknown command" + ;; +esac + +exec "$@"