Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yaml file for GHCR #281

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
name: Create and publish a Docker image

# Configures this workflow to run every time a PR is raised to the branch called `main`.
on:
pull_request:
branches: ['main']

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ruby:3.2-bullseye
RUN apt-get update && apt-get install -y nodejs npm


# Default directory
ENV INSTALL_PATH /opt/app
RUN mkdir -p $INSTALL_PATH

# Install rails

#RUN chown -R user:user /opt/app
WORKDIR /opt/app

COPY . .

RUN bundle install
RUN npm install

# Expose port 8888
EXPOSE 8888
owenblacker marked this conversation as resolved.
Show resolved Hide resolved

# Run a shell
#CMD ["bundle", "exec", "rails", "server"]
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0", "--port", "8888"]



2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ruby '~> 3.2.0'

gem 'dotenv-rails', groups: [:development]

gem 'lograge', '~> 0.12.0'
gem 'lograge', '~> 0.14.0'
gem 'logstash-event', '~> 1.2.02'
gem 'notifications-ruby-client', '~> 5.4.0'
gem 'octokit', '~> 6.1.0'
Expand Down
7 changes: 5 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ GEM
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
lograge (0.12.0)
lograge (0.14.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grit: are all the dependencies updated/patched to address any security concerns etc or are they to get the devenv up and running only atm? (will we patch/address dependabot issues in another ticket?).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter. Updating dependencies is separate in the backlog

actionpack (>= 4)
activesupport (>= 4)
railties (>= 4)
Expand Down Expand Up @@ -123,6 +123,8 @@ GEM
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.14.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.14.2-x86_64-linux)
racc (~> 1.4)
notifications-ruby-client (5.4.0)
Expand Down Expand Up @@ -234,12 +236,13 @@ GEM
zeitwerk (2.6.7)

PLATFORMS
arm64-darwin-22
x86_64-linux

DEPENDENCIES
dotenv-rails
listen (~> 3.7)
lograge (~> 0.12.0)
lograge (~> 0.14.0)
logstash-event (~> 1.2.02)
notifications-ruby-client (~> 5.4.0)
octokit (~> 6.1.0)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Running locally

This is a rails app, with dependencies managed by bundler. To run the app locally clone this repo, then:

```
```sh
bundle install
npm install
bundle exec rails server
Expand All @@ -18,14 +18,14 @@ If you want to test the apps interaction with third party services (e.g. GitHub
and GOV.UK Notify) you'll need to set up some secrets in environment variables.
The easiest way to do this in development is using a `.env` file (see [.env.example](.env.example)):

```
```sh
cp .env.example .env
$EDITOR .env
```

Run the tests with:

```
```sh
bundle exec rails test
```

Expand All @@ -38,6 +38,6 @@ This is continuously deployed from master [by Github Actions](https://github.com

To deploy to a separate route (e.g. for testing / previewing changes) you can push to PaaS manually:

```
```sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pebble: do we need new details in the readme to describe the dockerfile and how to build/use it locally?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes; that's still marked as to-do in ENG-83

cf push gds-request-an-aws-account-preview
```
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# yarn lockfile v1


"govuk-frontend@^4.5.0":
"integrity" "sha512-gZHDqf5vdlHjmx0NGJiNT12XLyR3d5KCS4AnlC3xTWOObJ0kQROrkIFyp3w4/PY3EQiYdgacVaJ6lizzygnzYw=="
"resolved" "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-4.5.0.tgz"
"version" "4.5.0"
govuk-frontend@^4.5.0:
version "4.5.0"
resolved "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-4.5.0.tgz"
integrity sha512-gZHDqf5vdlHjmx0NGJiNT12XLyR3d5KCS4AnlC3xTWOObJ0kQROrkIFyp3w4/PY3EQiYdgacVaJ6lizzygnzYw==
Loading