Skip to content

Commit

Permalink
Merge pull request #278 from alphagov/publish-to-dockerhub
Browse files Browse the repository at this point in the history
Publish to dockerhub
  • Loading branch information
Owen Blacker authored Jan 29, 2024
2 parents e8840e3 + d93664b commit 4c90e21
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 11 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/publish-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish image to Docker Hub

on:
push:
branches:
- 'main'
- 'master'
- 'development'
- 'releases/**'

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: governmentdigitalservice/ee-request-aws-account
tags: |
type=sha,enable=true,priority=100,prefix=sha-,suffix=,format=short
type=raw,value=latest,enable={{is_default_branch}}
# BUG: `type=semver,pattern={{version}}` is not outputting the semantic version

- name: Output tags
run: |
echo "tags: ${{ steps.meta.outputs.tags }}"
# BUG: This is not echoing locally with `act`

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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



# 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)
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
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==

0 comments on commit 4c90e21

Please sign in to comment.