-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2357 from alphagov/alexbakervr/prepare-app-for-mi…
…gration Adding new Dockerfile, puma.rb and ci.yaml files
- Loading branch information
Showing
3 changed files
with
58 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require "govuk_app_config/govuk_puma" | ||
GovukPuma.configure_rails(self) |