diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml index ac4fd85c90..59ba4f460c 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/CD.yml @@ -15,3 +15,5 @@ jobs: build: name: 🔨 Build and deploy docker image uses: WGBH-MLA/.github/.github/workflows/build.yml@main + with: + target: production diff --git a/Dockerfile b/Dockerfile index fa89b26721..166f2ce5f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM ruby:2.4.4 +FROM ruby:2.4.4 as base WORKDIR /usr/src/app RUN /bin/echo -e "deb http://archive.debian.org/debian stretch main\ndeb http://archive.debian.org/debian-security stretch/updates main\n" > /etc/apt/sources.list -RUN apt update && apt install -y nodejs curl libcurl3 libcurl3-openssl-dev openjdk-8-jdk && apt-get clean +RUN apt update && apt install -y nodejs curl libcurl3 libcurl3-openssl-dev openjdk-8-jdk COPY Gemfile Gemfile.lock ./ @@ -11,8 +11,17 @@ RUN bundle install EXPOSE 3000 +CMD rake jetty:clean && rake jetty:config && rake jetty:start && bundle exec rake db:migrate RAILS_ENV=development && bundle exec rails s -b 0.0.0.0 + +FROM base as production + RUN apt-get autoremove -y \ && apt-get clean -y \ && rm -rf /var/lib/apt/lists/* -CMD rake jetty:clean && rake jetty:config && rake jetty:start && bundle exec rake db:migrate RAILS_ENV=development && bundle exec rails s -b 0.0.0.0 + +COPY . . + +RUN rake jetty:clean && rake jetty:config + +CMD rake jetty:start && bundle exec rake db:migrate RAILS_ENV=production && bundle exec rails s -b 0.0.0.0