Skip to content

Commit 3bbdc70

Browse files
Merge pull request #20 from citizensadvice/v2.1.0
v2.1.0
2 parents 4889797 + 8a88312 commit 3bbdc70

File tree

19 files changed

+610
-225
lines changed

19 files changed

+610
-225
lines changed

.Dockerfile.swp

12 KB
Binary file not shown.

.github/workflows/main.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build and publish to public ECR
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "[0-9]*"
8+
- "v[0-9]*"
9+
tags:
10+
- v*
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Git Checkout
16+
uses: actions/checkout@v3
17+
- name: Build
18+
run: |
19+
docker build -t image-resizer .
20+
- name: Lint
21+
run: |
22+
docker-compose run --rm app bundle exec rubocop
23+
- name: Test
24+
run: |
25+
docker-compose run -e APP_ENV=test --rm app bundle exec rspec
26+
27+
build:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v2
32+
- name: Extract repo name
33+
shell: bash
34+
run: echo "##[set-output name=repo_name;]$(echo ${GITHUB_REPOSITORY} | sed "s/.*\///g" | sed "s/-docker$//")"
35+
id: extract_repo_name
36+
- name: Docker meta
37+
id: docker_meta
38+
uses: crazy-max/ghaction-docker-meta@v1
39+
with:
40+
images: public.ecr.aws/citizensadvice/${{ steps.extract_repo_name.outputs.repo_name }}
41+
tag-sha: true
42+
- name: Login to AWS Elastic Container Registry
43+
uses: docker/login-action@v1
44+
with:
45+
registry: public.ecr.aws
46+
username: ${{ secrets.PUBLIC_PUSH_ECR_AWS_KEY }}
47+
password: ${{ secrets.PUBLIC_PUSH_ECR_AWS_SECRET }}
48+
env:
49+
AWS_REGION: us-east-1
50+
- name: Set up QEMU
51+
uses: docker/setup-qemu-action@v2
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v2
54+
- name: Build and push
55+
id: docker_build
56+
uses: docker/build-push-action@v3
57+
with:
58+
context: .
59+
push: true
60+
platforms: linux/amd64,linux/arm64
61+
tags: ${{ steps.docker_meta.outputs.tags }}
62+
labels: ${{ steps.docker_meta.outputs.labels }}

.github/workflows/push.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.2
1+
3.2.0

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# CHANGELOG
22

3+
## v2.1.0 _2023-01-31_
4+
5+
- `mime_type` param is no longer required. The application will now determine the mime-type.
6+
- `height` is now an optional parameter (default 800)
7+
- `width` is now an optional parameter (default 800)
8+
- svgs will now be optimised
9+
- inputs now have better validation
10+
- include newrelic_rpm
11+
312
## v2.0.0 _2022-07-04_
413

514
- Add arm64 compatibility

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:3.1.2-alpine3.16 as builder
1+
FROM ruby:3.2.0-alpine3.17 as builder
22

33
ENV LANG C.UTF-8
44
WORKDIR /app
@@ -17,14 +17,14 @@ RUN gem install bundler \
1717

1818
#################################################
1919

20-
FROM ruby:3.1.2-alpine3.16
20+
FROM ruby:3.2.0-alpine3.17
2121

2222
WORKDIR /app
2323
ENV RACK_ENV=production
2424

2525
RUN apk update \
2626
&& apk upgrade \
27-
&& apk --no-cache add imagemagick tiff-tools
27+
&& apk --no-cache add imagemagick tiff-tools file gcompat
2828

2929
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
3030

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
source "https://rubygems.org"
44
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
55

6-
ruby "3.1.2"
6+
ruby "3.2.0"
77

88
gem "image_processing"
99
gem "puma"
1010
gem "sinatra"
1111
gem "sinatra-contrib", require: false
12+
gem "svg_optimizer"
13+
14+
gem "newrelic_rpm"
1215

1316
group :development, :test do
1417
gem "citizens-advice-style", github: "citizensadvice/citizens-advice-style-ruby", tag: "v9.0.0"

Gemfile.lock

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,22 @@ GEM
2626
multi_json (1.15.0)
2727
mustermann (1.1.1)
2828
ruby2_keywords (~> 0.0.1)
29+
newrelic_rpm (8.15.0)
2930
nio4r (2.5.8)
31+
nokogiri (1.14.1-aarch64-linux)
32+
racc (~> 1.4)
33+
nokogiri (1.14.1-arm64-darwin)
34+
racc (~> 1.4)
35+
nokogiri (1.14.1-x86_64-darwin)
36+
racc (~> 1.4)
37+
nokogiri (1.14.1-x86_64-linux)
38+
racc (~> 1.4)
3039
parallel (1.22.1)
3140
parser (3.1.2.0)
3241
ast (~> 2.4.1)
3342
puma (5.6.4)
3443
nio4r (~> 2.0)
44+
racc (1.6.2)
3545
rack (2.2.4)
3646
rack-protection (2.2.0)
3747
rack
@@ -83,24 +93,31 @@ GEM
8393
rack-protection (= 2.2.0)
8494
sinatra (= 2.2.0)
8595
tilt (~> 2.0)
96+
svg_optimizer (0.2.6)
97+
nokogiri
8698
tilt (2.0.10)
8799
unicode-display_width (2.2.0)
88100

89101
PLATFORMS
90-
ruby
102+
aarch64-linux-musl
103+
arm64-darwin-21
104+
x86_64-darwin-21
105+
x86_64-linux-musl
91106

92107
DEPENDENCIES
93108
citizens-advice-style!
94109
debug
95110
image_processing
111+
newrelic_rpm
96112
puma
97113
rack-test
98114
rspec
99115
sinatra
100116
sinatra-contrib
117+
svg_optimizer
101118

102119
RUBY VERSION
103-
ruby 3.1.2p20
120+
ruby 3.2.0p0
104121

105122
BUNDLED WITH
106-
2.3.17
123+
2.4.5

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ A Ruby app to resize images built with the Sinatra web framework and ImageMagick
66

77
The endpoint for resizing images is `/image` and it requires the params posted as multi-part form data.
88

9-
- `mime_type` for example `image/png`
10-
- `image_file` for example an image in the format `.png, .jpg, .gif, and .tif`
9+
- `image_file` the image to be resized
10+
- `width` max width of the resized image in pixels. Defaults to 800
11+
- `height` max height of the resized image in pixels. Defaults to 800
1112

12-
Image files in the format `TIFF` are converted to `PNG` automatically.
13+
Images will be resized maintaining their aspect ratio.
1314

14-
The returned images are only resized if they have dimensions larger than `800px`, in which case they are resized maintaining their aspect ratio so their dimensions are a maximum of `900px`.
15+
Images that or not a png, gif, svg or jpeg will be converted to a png.
16+
The full list of supported image types is whatever installed version of imagemagick supports.
17+
18+
SVG images will be optimised, but not have their dimensions modified.
1519

1620
## Local development
1721

0 commit comments

Comments
 (0)