Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

Commit 9fb7c22

Browse files
committed
Prepare for v0.5.3.0 release.
1 parent 3119f47 commit 9fb7c22

8 files changed

+167
-45
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!-- -*- mode: markdown -*- -->
2+
# Keep A Changelog!
3+
4+
See this http://keepachangelog.com link for information on how we want this documented formatted.
5+
6+
## v0.5.3.0
7+
8+
### Added
9+
10+
- Initial Release!!! 🎉🎊🥳

CODE_OF_CONDUCT.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at ken@metaskills.net. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at [http://contributor-covenant.org/version/1/4][version]
72+
73+
[homepage]: http://contributor-covenant.org
74+
[version]: http://contributor-covenant.org/version/1/4/

Dockerfile

+24-11
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,34 @@ ENV PATH=/opt/bin:$PATH
88
ENV LD_LIBRARY_PATH=/opt/lib:/opt/lib64:$LD_LIBRARY_PATH
99
ENV MYSQL_VERSION=$MYSQL_VERSION
1010

11-
RUN echo '== MariaDB =='
12-
RUN git clone https://github.com/MariaDB/server.git && \
13-
cd ./server && \
14-
git checkout 10.3 && \
15-
cmake . \
16-
-DCMAKE_INSTALL_PREFIX=/opt \
17-
-DWITHOUT_TOKUDB=1 && \
11+
RUN echo '== patchelf =='
12+
RUN git clone https://github.com/NixOS/patchelf.git && \
13+
cd ./patchelf && \
14+
git checkout 0.11 && \
15+
./bootstrap.sh && \
16+
./configure --prefix=/opt && \
1817
make && \
1918
make install
2019

21-
RUN echo '== Install MySQL2 =='
22-
RUN rm -rf /opt/lib/libmariadb.so* && \
20+
RUN echo '== MySQL Connector =='
21+
RUN curl -L https://downloads.mysql.com/archives/get/p/19/file/mysql-connector-c-6.1.11-src.tar.gz > mysql-connector-c-6.1.11-src.tar.gz && \
22+
tar -xf mysql-connector-c-6.1.11-src.tar.gz && \
23+
cd mysql-connector-c-6.1.11-src && \
24+
cmake . -DCMAKE_BUILD_TYPE=Release && \
25+
make && \
26+
make install
27+
28+
RUN echo '== Install MySQL2 Gem =='
29+
RUN rm -rf /usr/local/mysql/lib/libmysqlclient.so* && \
2330
gem install mysql2 \
24-
-v $MYSQL_VERSION \
25-
-- --with-mysql-dir=/opt
31+
-v $MYSQL_VERSION \
32+
-- --with-mysql-dir=/usr/local/mysql
33+
34+
RUN echo '== Patch MySQL2 Gem =='
35+
RUN patchelf --add-needed librt.so.1 \
36+
/var/runtime/gems/mysql2-0.5.3/lib/mysql2/mysql2.so && \
37+
patchelf --add-needed libstdc++.so.6 \
38+
/var/runtime/gems/mysql2-0.5.3/lib/mysql2/mysql2.so
2639

2740
RUN echo '== Share Files =='
2841
RUN mkdir -p /build/share && \

README.md

+39-19
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,52 @@
1+
# MySQL2 Lambda Gem
12

2-
# Lamby MySQL Layer
3+
<a href="https://github.com/customink/lamby"><img src="https://user-images.githubusercontent.com/2381/59363668-89edeb80-8d03-11e9-9985-2ce14361b7e3.png" alt="Lamby: Simple Rails & AWS Lambda Integration using Rack." align="right" width="300" /></a>Very simple [Mysql2](https://github.com/brianmario/mysql2) gem precompiled for Amazon Linux 1 & 2 (Ruby 2.5 & 2.7) with statically linked `libmysqlclient` ready for any AWS Lambda usage, including Rails.
34

4-
Installs dependencies for [customink/foundry](https://github.com/customink/foundry) on Lambda.
5-
6-
## Usage
5+
```ruby
6+
gem 'mysql2-lambda'
7+
```
78

8-
* Clone or fork this repository.
9-
* Make sure you have Docker or AWS CLI installed.
10-
* Run `./bin/deploy` or `./bin/deploy-${stage}` scripts.
9+
Part of a suite of open source projects from **[Lamby: Simple Rails & AWS Lambda Integration using Rack.](https://github.com/customink/lamby)** Details include:
1110

12-
From there you simply use the arn in your AWS SAM `template.yaml` file.
11+
- Tested on Ruby 2.5.x & 2.7.x
12+
- Small Size! Only 5 Megabytes. No Lambda Layers needed!
13+
- Works with any MySQL connection. Including RDS Proxy.
1314

14-
## Dependencies
15+
## Methodology
1516

16-
...
17+
We used the `lambci/lambda:build-ruby2.5` Docker image from the [docker-lambda](https://github.com/lambci/docker-lambda) project to build the MySQL Connector/C's `libmysqlclient`. From there we ensure the Mysql2 gem statically includes that library. The resulting packaged gem and `mysql2.so` file looks something like this.
18+
19+
```shell
20+
$ ldd mysql2.so
21+
linux-vdso.so.1 => (0x00007ffcb15d4000)
22+
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fa8ebd21000)
23+
librt.so.1 => /lib64/librt.so.1 (0x00007fa8ebb19000)
24+
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa8eb8fd000)
25+
libgmp.so.10 => /usr/lib64/libgmp.so.10 (0x00007fa8eb687000)
26+
libdl.so.2 => /lib64/libdl.so.2 (0x00007fa8eb483000)
27+
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fa8eb24c000)
28+
libm.so.6 => /lib64/libm.so.6 (0x00007fa8eaf4a000)
29+
libc.so.6 => /lib64/libc.so.6 (0x00007fa8eab7c000)
30+
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fa8ea966000)
31+
/lib64/ld-linux-x86-64.so.2 (0x00007fa8ec72e000)
32+
libfreebl3.so => /lib64/libfreebl3.so (0x00007fa8ea764000)
33+
```
1734

18-
## Layer Size
35+
## Development
1936

20-
In `/opt/lib64/mysql`
37+
Clone or fork this repository, make sure you have Docker installed, then run the following commands.
2138

22-
```
23-
lrwxrwxrwx 1 root 17 Jul 2 00:49 libmysqlclient_r.so -> libmysqlclient.so
24-
lrwxrwxrwx 1 root 20 Jul 2 00:49 libmysqlclient.so -> libmysqlclient.so.18
25-
lrwxrwxrwx 1 root 24 Jul 2 00:49 libmysqlclient.so.18 -> libmysqlclient.so.18.0.0
26-
-rwxr-xr-x 1 root 2983624 Dec 3 2018 libmysqlclient.so.18.0.0
39+
```shell
40+
./bin/setup
41+
./bin/build
2742
```
2843

44+
You will now have a packaged gem in the root of your project.
2945

30-
## Methodology
46+
## License
47+
48+
Thanks to all the contributors of the `Mysql2` (https://github.com/brianmario/mysql2) gem. The license here is the same as that. MIT.
49+
50+
## Code of Conduct
3151

32-
We used the `lambci/lambda:build-ruby2.5` Docker image from the [docker-lambda](https://github.com/lambci/docker-lambda) project.
52+
Everyone interacting in the Mysql2 Lambda project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/customink/mysql2-lambda/blob/master/CODE_OF_CONDUCT.md).

bin/build

+2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ docker run \
1717
rm -rf ./gem && mkdir ./gem
1818
cp -r ./share/* ./gem
1919
cp ./README.md ./gem
20+
cp ./CHANGELOG.md ./gem
2021
cp ./mysql2-lambda.gemspec ./gem
22+
cp ./lib/mysql2-lambda.rb ./gem/lib
2123

2224
pushd ./gem
2325

bin/console

-13
This file was deleted.

lib/mysql2-lambda.rb

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Not perfect. Simple `gem` hack to avoid the
2+
# Mysql2Adapter in ActiveREcord from using rubygems.
3+
#
4+
if defined?(Rails)
5+
$ORIG_GEM_METHOD = method(:gem)
6+
kernel = (class << ::Kernel; self; end)
7+
[kernel, ::Kernel].each do |k|
8+
k.send :remove_method, :gem
9+
k.send :define_method, :gem do |dep, *reqs|
10+
unless ['mysql2'].include?(dep)
11+
$ORIG_GEM_METHOD.call(dep, *reqs)
12+
end
13+
end
14+
k.send :public, :gem
15+
end
16+
end

mysql2-lambda.gemspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Gem::Specification.new do |s|
22
s.name = 'mysql2-lambda'
3-
s.version = '0.5.3.beta.1'
3+
s.version = '0.5.3.0'
44
s.authors = ['Ken Collins']
55
s.license = "MIT"
66
s.email = ['kcollins@customink.com']
77
s.homepage = 'https://github.com/customink/mysql2-lambda'
88
s.rdoc_options = ['--charset=UTF-8']
9-
s.summary = 'Precompiled Mysql2 gem for AWS Lambda using MariaDB.'
9+
s.summary = 'Precompiled Mysql2 gem for AWS Lambda.'
1010
s.metadata = {
1111
'bug_tracker_uri' => "#{s.homepage}/issues",
1212
'changelog_uri' => "#{s.homepage}/releases/tag/#{s.version}",

0 commit comments

Comments
 (0)