phaedra 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/example/Dockerfile +46 -0
- data/example/api/simple.rb +1 -1
- data/example/api/the-time.rb +2 -2
- data/example/docker-compose.yml +8 -0
- data/lib/phaedra.rb +1 -0
- data/lib/phaedra/startup_initializers.rb +9 -0
- data/lib/phaedra/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00d5ba6f3bc10860baef3bf63867665db4ef610b7cf14a8281495cf929339bc3
|
4
|
+
data.tar.gz: 5d1c500a8cbe79a89182497e7881fdeba3d129e5e2f2ddcce19012f9ae713171
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f3a8145df4a02f5362dfffb66f1de44ccd650425504007f2f49fa666c68bd9d228d0e8ade98daa2d318c57b220013009bd2c9b37d10d375a7cecca2cee0c4ac
|
7
|
+
data.tar.gz: f0effbf926248e56c67da411bd688cc3f6783d7710bdedf141029d523b4e55667df18b1e509cb68aa55795a01b74369ac8e007a91754ac9b3c6046741d166258
|
data/README.md
CHANGED
@@ -118,7 +118,13 @@ All you have to do is create a static site repo ([Bridgetown](https://www.bridge
|
|
118
118
|
|
119
119
|
We recommend using OpenFaaS' dockerfile template so you can define your own `Dockerfile` to book Rack + Phaedra using the Puma web server. This also allows you to customize the Docker image configuration to install and configure other tools as necessary.
|
120
120
|
|
121
|
-
First
|
121
|
+
First make sure you've added Puma to your Gemfile:
|
122
|
+
|
123
|
+
```
|
124
|
+
gem "puma"
|
125
|
+
```
|
126
|
+
|
127
|
+
Then make sure you've pulled down the OpenFaaS template:
|
122
128
|
|
123
129
|
```sh
|
124
130
|
faas-cli template store pull dockerfile
|
@@ -174,7 +180,7 @@ Next add the `config.ru` file to boot Rack:
|
|
174
180
|
```ruby
|
175
181
|
# testphaedra/config.ru
|
176
182
|
|
177
|
-
require "phaedra"
|
183
|
+
require "phaedra/rack_app"
|
178
184
|
|
179
185
|
run Phaedra::RackApp.new
|
180
186
|
```
|
@@ -210,7 +216,7 @@ In case you're wondering: yes, with Phaedra you can write multiple Ruby function
|
|
210
216
|
Booting Phaedra up as Rack app is very simple. All you need to do is add a `config.ru` file alongside your `api` folder:
|
211
217
|
|
212
218
|
```ruby
|
213
|
-
require "phaedra"
|
219
|
+
require "phaedra/rack_app"
|
214
220
|
|
215
221
|
run Phaedra::RackApp.new
|
216
222
|
```
|
data/example/Dockerfile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
FROM ruby:2.6-alpine3.11 as builder
|
2
|
+
|
3
|
+
RUN apk add --no-cache --virtual \\
|
4
|
+
#
|
5
|
+
# required
|
6
|
+
bash tzdata build-base libffi-dev \\
|
7
|
+
#
|
8
|
+
# nice to haves
|
9
|
+
curl git
|
10
|
+
|
11
|
+
FROM builder as phaedra-app
|
12
|
+
|
13
|
+
# This is to fix an issue on Linux with permissions issues
|
14
|
+
ARG USER_ID=${USER_ID:-1000}
|
15
|
+
ARG GROUP_ID=${GROUP_ID:-1000}
|
16
|
+
ARG DOCKER_USER=${DOCKER_USER:-user}
|
17
|
+
ARG APP_DIR=${APP_DIR:-/home/user/phaedra-app}
|
18
|
+
|
19
|
+
# Change with --build-arg PHAEDRA_ENV=production
|
20
|
+
ARG PHAEDRA_ENV=staging
|
21
|
+
ENV PHAEDRA_ENV=$PHAEDRA_ENV
|
22
|
+
|
23
|
+
# Create a non-root user
|
24
|
+
RUN addgroup -g $GROUP_ID -S $GROUP_ID
|
25
|
+
RUN adduser --disabled-password -G $GROUP_ID --uid $USER_ID -S $DOCKER_USER
|
26
|
+
|
27
|
+
# Create and then own the directory to fix permissions issues
|
28
|
+
RUN mkdir -p $APP_DIR
|
29
|
+
RUN chown -R $USER_ID:$GROUP_ID $APP_DIR
|
30
|
+
|
31
|
+
# Define the user running the container
|
32
|
+
USER $USER_ID:$GROUP_ID
|
33
|
+
|
34
|
+
# . now == $APP_DIR
|
35
|
+
WORKDIR $APP_DIR
|
36
|
+
|
37
|
+
# COPY is run as a root user, not as the USER defined above, so we must chown it
|
38
|
+
COPY --chown=$USER_ID:$GROUP_ID Gemfile* ./
|
39
|
+
RUN gem install bundler
|
40
|
+
RUN bundle install
|
41
|
+
|
42
|
+
COPY --chown=$USER_ID:$GROUP_ID . .
|
43
|
+
|
44
|
+
EXPOSE 8080
|
45
|
+
|
46
|
+
CMD ["bundle", "exec", "rackup", "-p", "8080", "-o", "0.0.0.0"]
|
data/example/api/simple.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative "../phaedra/initializers"
|
|
3
3
|
class PhaedraFunction < Phaedra::Base
|
4
4
|
def get(params)
|
5
5
|
response["Content-Type"] = "text/html; charset=utf-8"
|
6
|
-
"<p
|
6
|
+
"<p>😁 #{Phaedra.the_time} - #{ENV["PHAEDRA_ENV"]} - #{Time.new}</p>"
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
data/example/api/the-time.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
require_relative "../phaedra/initializers"
|
2
2
|
|
3
3
|
class PhaedraFunction < Phaedra::Base
|
4
4
|
before_action :earlier_stuff
|
5
5
|
|
6
6
|
def get(params)
|
7
|
-
"The
|
7
|
+
"The ?search param is #{params[:search]}"
|
8
8
|
end
|
9
9
|
|
10
10
|
def post(params)
|
data/lib/phaedra.rb
CHANGED
data/lib/phaedra/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phaedra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared White
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -80,10 +80,12 @@ files:
|
|
80
80
|
- LICENSE.txt
|
81
81
|
- README.md
|
82
82
|
- Rakefile
|
83
|
+
- example/Dockerfile
|
83
84
|
- example/Gemfile
|
84
85
|
- example/api/simple.rb
|
85
86
|
- example/api/the-time.rb
|
86
87
|
- example/config.ru
|
88
|
+
- example/docker-compose.yml
|
87
89
|
- example/phaedra/initializers.rb
|
88
90
|
- lib/phaedra.rb
|
89
91
|
- lib/phaedra/base.rb
|
@@ -93,6 +95,7 @@ files:
|
|
93
95
|
- lib/phaedra/rack_middleware.rb
|
94
96
|
- lib/phaedra/rack_middleware/not_found.rb
|
95
97
|
- lib/phaedra/rack_middleware/static.rb
|
98
|
+
- lib/phaedra/startup_initializers.rb
|
96
99
|
- lib/phaedra/version.rb
|
97
100
|
- phaedra.gemspec
|
98
101
|
homepage: https://github.com/whitefusionhq/phaedra
|
@@ -114,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
117
|
- !ruby/object:Gem::Version
|
115
118
|
version: '0'
|
116
119
|
requirements: []
|
117
|
-
rubygems_version: 3.0.
|
120
|
+
rubygems_version: 3.0.8
|
118
121
|
signing_key:
|
119
122
|
specification_version: 4
|
120
123
|
summary: Write serverless Ruby functions via a REST-like microframework compatible
|