Skip to content

Commit

Permalink
Merge pull request #2357 from alphagov/alexbakervr/prepare-app-for-mi…
Browse files Browse the repository at this point in the history
…gration

Adding new Dockerfile, puma.rb and ci.yaml files
  • Loading branch information
bilbof authored Feb 10, 2022
2 parents ac3be00 + 3c71b0e commit 0ec1788
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 17 deletions.
19 changes: 19 additions & 0 deletions .github/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build and publish to ECR

on:
workflow_dispatch:
branches:
- main
push:
branches:
- main
paths-ignore:
- "Jenkinsfile"
- ".git**"

jobs:
build-publish-image-to-ecr:
uses: alphagov/govuk-infrastructure/.github/workflows/ci-ecr.yaml@main
secrets:
AWS_GOVUK_ECR_ACCESS_KEY_ID: ${{ secrets.AWS_GOVUK_ECR_ACCESS_KEY_ID }}
AWS_GOVUK_ECR_SECRET_ACCESS_KEY: ${{ secrets.AWS_GOVUK_ECR_SECRET_ACCESS_KEY }}
54 changes: 37 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
FROM ruby:2.7.5
RUN apt-get update -qq && apt-get upgrade -y
RUN apt-get install -y build-essential nodejs && apt-get clean
RUN gem install foreman
ARG base_image=ruby:2.7.5-slim

ENV GOVUK_APP_NAME government-frontend
ENV PORT 3090
ENV RAILS_ENV development
FROM $base_image AS builder

ENV APP_HOME /app
RUN mkdir $APP_HOME
ENV RAILS_ENV=production
# TODO: have a separate build image which already contains the build-only deps.
RUN apt-get update -qy && \
apt-get upgrade -y && \
apt-get install -y build-essential nodejs && \
apt-get clean

RUN bundle config set force_ruby_platform true

WORKDIR $APP_HOME
ADD Gemfile* $APP_HOME/
ADD .ruby-version $APP_HOME/
RUN bundle install
RUN mkdir /app

ADD . $APP_HOME
WORKDIR /app

RUN GOVUK_WEBSITE_ROOT=https://www.gov.uk GOVUK_APP_DOMAIN=www.gov.uk RAILS_ENV=production bundle exec rails assets:precompile
COPY Gemfile Gemfile.lock .ruby-version /app/

HEALTHCHECK CMD curl --silent --fail localhost:$PORT/healthcheck/ready || exit 1
RUN bundle config set deployment 'true' && \
bundle config set without 'development test' && \
bundle install --jobs 4 --retry=2

CMD foreman run web
COPY . /app
# TODO: We probably don't want assets in the image; remove this once we have a proper deployment process which uploads to (e.g.) S3.
RUN GOVUK_APP_DOMAIN=www.gov.uk \
GOVUK_WEBSITE_ROOT=https://www.gov.uk \
bundle exec rails assets:precompile

FROM $base_image

ENV RAILS_ENV=production GOVUK_APP_NAME=government-frontend GOVUK_APP_DOMAIN=www.gov.uk GOVUK_WEBSITE_ROOT=https://www.gov.uk PORT=3090

RUN apt-get update -qy && \
apt-get upgrade -y && \
apt-get install -y nodejs && \
apt-get clean

WORKDIR /app

COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
COPY --from=builder /app ./

CMD bundle exec puma
2 changes: 2 additions & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require "govuk_app_config/govuk_puma"
GovukPuma.configure_rails(self)

0 comments on commit 0ec1788

Please sign in to comment.