Skip to content

Commit 896f3ec

Browse files
committed
cleanup + update to latest ruby
1 parent 7b6a4f9 commit 896f3ec

File tree

12 files changed

+116
-63
lines changed

12 files changed

+116
-63
lines changed

.dockerignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1+
.dockerignore
2+
.editorconfig
13
.git/
2-
README.md
4+
.github/
5+
.gitignore
6+
Dockerfile
7+
LICENSE.txt
8+
*.md
9+
*.sh

.github/workflows/gcr-deploy.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build and deploy to Google Cloud Run
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
# Environment variables available to all jobs and steps in this workflow
9+
env:
10+
PROJECT_ID: ${{ secrets.RUN_PROJECT }}
11+
RUN_REGION: ${{ secrets.RUN_REGION }}
12+
SERVICE_NAME: ${{ secrets.RUN_SERVICE }}
13+
14+
jobs:
15+
setup-build-deploy:
16+
name: Setup, Build, and Deploy
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v1
22+
23+
# Setup gcloud CLI
24+
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
25+
with:
26+
version: '275.0.0'
27+
service_account_email: ${{ secrets. GCP_SA_EMAIL }}
28+
service_account_key: ${{ secrets. GCP_SA_KEY }}
29+
30+
# Configure gcloud CLI
31+
- name: gcloud Set up
32+
run: |
33+
gcloud config set project $PROJECT_ID
34+
35+
# Build and push image to Google Container Registry
36+
- name: Build
37+
run: |
38+
docker build \
39+
--build-arg COMMIT=${GITHUB_SHA:0:7} \
40+
--build-arg LASTMOD=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
41+
--tag gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA .
42+
43+
- name: GCloud auth to docker
44+
run: |
45+
gcloud auth configure-docker
46+
47+
- name: Push to registry
48+
run: |
49+
docker push gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA
50+
51+
# Deploy image to Cloud Run
52+
- name: Deploy
53+
run: |
54+
gcloud run deploy $SERVICE_NAME \
55+
--allow-unauthenticated \
56+
--image gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA \
57+
--platform managed \
58+
--project ${PROJECT_ID} \
59+
--region $RUN_REGION

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:2.5.7
1+
FROM ruby:2.7.1
22

33
# throw errors if Gemfile has been modified since Gemfile.lock
44
RUN bundle config --global frozen 1
@@ -10,6 +10,11 @@ RUN bundle install
1010

1111
COPY . .
1212

13+
ARG COMMIT="(not set)"
14+
ARG LASTMOD="(not set)"
15+
ENV COMMIT=$COMMIT
16+
ENV LASTMOD=$LASTMOD
17+
1318
EXPOSE 4567
1419
CMD ["./regexplanet.rb"]
1520

Gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
source "https://rubygems.org"
2-
ruby '2.5.7'
2+
ruby '2.7.1'
33
gem 'sinatra'
44
gem 'sinatra-contrib'
55
gem 'sinatra-jsonp'
6-
gem 'thin'

Gemfile.lock

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,30 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (5.2.1.1)
5-
concurrent-ruby (~> 1.0, >= 1.0.2)
6-
i18n (>= 0.7, < 2)
7-
minitest (~> 5.1)
8-
tzinfo (~> 1.1)
9-
backports (3.11.4)
10-
concurrent-ruby (1.1.3)
11-
daemons (1.2.6)
12-
eventmachine (1.2.7)
13-
i18n (1.1.1)
14-
concurrent-ruby (~> 1.0)
15-
minitest (5.11.3)
16-
multi_json (1.13.1)
17-
mustermann (1.0.3)
18-
rack (2.0.8)
19-
rack-protection (2.0.4)
4+
backports (3.17.2)
5+
multi_json (1.14.1)
6+
mustermann (1.1.1)
7+
ruby2_keywords (~> 0.0.1)
8+
rack (2.2.2)
9+
rack-protection (2.0.8.1)
2010
rack
21-
sinatra (2.0.4)
11+
ruby2_keywords (0.0.2)
12+
sinatra (2.0.8.1)
2213
mustermann (~> 1.0)
2314
rack (~> 2.0)
24-
rack-protection (= 2.0.4)
15+
rack-protection (= 2.0.8.1)
2516
tilt (~> 2.0)
26-
sinatra-contrib (2.0.4)
27-
activesupport (>= 4.0.0)
17+
sinatra-contrib (2.0.8.1)
2818
backports (>= 2.8.2)
2919
multi_json
3020
mustermann (~> 1.0)
31-
rack-protection (= 2.0.4)
32-
sinatra (= 2.0.4)
33-
tilt (>= 1.3, < 3)
21+
rack-protection (= 2.0.8.1)
22+
sinatra (= 2.0.8.1)
23+
tilt (~> 2.0)
3424
sinatra-jsonp (0.5.0)
3525
multi_json (~> 1.8)
3626
sinatra (>= 1.0)
37-
thin (1.7.2)
38-
daemons (~> 1.0, >= 1.0.9)
39-
eventmachine (~> 1.0, >= 1.0.4)
40-
rack (>= 1, < 3)
41-
thread_safe (0.3.6)
42-
tilt (2.0.9)
43-
tzinfo (1.2.5)
44-
thread_safe (~> 0.1)
27+
tilt (2.0.10)
4528

4629
PLATFORMS
4730
ruby
@@ -50,10 +33,9 @@ DEPENDENCIES
5033
sinatra
5134
sinatra-contrib
5235
sinatra-jsonp
53-
thin
5436

5537
RUBY VERSION
56-
ruby 2.5.3p105
38+
ruby 2.7.1p83
5739

5840
BUNDLED WITH
59-
1.16.2
41+
2.1.4

Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
# regexplanet-ruby
1+
# RegexPlanet Ruby [<img alt="Ruby Logo" src="https://www.vectorlogo.zone/logos/ruby-lang/ruby-lang-icon.svg" height="90" align="right" />](https://www.ruby-lang.org/)
22

33
This is the Ruby backend for RegexPlanet, a tool for online regular expression testing.
44

5-
See [API docs](http://www.regexplanet.com/support/api.html) for what it is supposed to do.
5+
Use [Ruby online regex test page](http://www.regexplanet.com/advanced/ruby/index.html) to test your regular expressions.
66

7-
See [Ruby online regex test page](http://www.regexplanet.com/advanced/ruby/index.html) to use it to test your regular expressions.
7+
See the [API docs](http://www.regexplanet.com/support/api.html) for what it is supposed to do.
88

99
## Notes
1010

1111
* [Ruby on Docker](https://docs.docker.com/samples/library/ruby/)
12+
* [updating Gemfile.lock](https://stackoverflow.com/questions/13101945/how-to-re-sync-gemfile-lock-on-changes-to-gemfile/13102274#13102274)
1213

1314
## Credits
15+
[![Docker](https://www.vectorlogo.zone/logos/docker/docker-ar21.svg)](https://www.docker.com/ "Deployment")
16+
[![Git](https://www.vectorlogo.zone/logos/git-scm/git-scm-ar21.svg)](https://git-scm.com/ "Version control")
17+
[![Github](https://www.vectorlogo.zone/logos/github/github-ar21.svg)](https://github.com/ "Code hosting")
18+
[![Google Cloud Run](https://www.vectorlogo.zone/logos/google_cloud_run/google_cloud_run-ar21.svg)](https://cloud.google.com/run/ "Hosting")
19+
[![Ruby](https://www.vectorlogo.zone/logos/ruby-lang/ruby-lang-ar21.svg)](https://www.ruby-lang.org/ "Code")
1420

15-
* Ruby
16-
* Docker
17-
* Zeit
18-
* Sinatra
21+
* [Bundler](https://bundler.io/)
22+
* [Rack](https://rack.github.io/)
23+
* [RubyGems](https://rubygems.org/)
24+
* [Sinatra](http://sinatrarb.com/)

app.yaml

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

docker-run.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
4+
docker build -t regexplanet-ruby .
5+
docker run \
6+
--expose 4000 \
7+
--env COMMIT=$(git rev-parse --short HEAD)-local \
8+
--env LASTMOD=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
9+
--env PORT='4000' \
10+
--publish 4000:4000 \
11+
regexplanet-ruby
12+

now.json

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

0 commit comments

Comments
 (0)