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

Commit 3119f47

Browse files
committedJul 4, 2020
MariaDB.
0 parents  commit 3119f47

File tree

10 files changed

+175
-0
lines changed

10 files changed

+175
-0
lines changed
 

‎.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/share
2+
/gem
3+
*.gem

‎Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM lambci/lambda:build-ruby2.5
2+
3+
WORKDIR /build
4+
5+
ARG MYSQL_VERSION
6+
7+
ENV PATH=/opt/bin:$PATH
8+
ENV LD_LIBRARY_PATH=/opt/lib:/opt/lib64:$LD_LIBRARY_PATH
9+
ENV MYSQL_VERSION=$MYSQL_VERSION
10+
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 && \
18+
make && \
19+
make install
20+
21+
RUN echo '== Install MySQL2 =='
22+
RUN rm -rf /opt/lib/libmariadb.so* && \
23+
gem install mysql2 \
24+
-v $MYSQL_VERSION \
25+
-- --with-mysql-dir=/opt
26+
27+
RUN echo '== Share Files =='
28+
RUN mkdir -p /build/share && \
29+
cp -r /var/runtime/gems/mysql2-$MYSQL_VERSION/* /build/share && \
30+
rm -rf /build/share/ext \
31+
/build/share/README.md \
32+
/build/share/support

‎LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Brian Lopez
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
# Lamby MySQL Layer
3+
4+
Installs dependencies for [customink/foundry](https://github.com/customink/foundry) on Lambda.
5+
6+
## Usage
7+
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.
11+
12+
From there you simply use the arn in your AWS SAM `template.yaml` file.
13+
14+
## Dependencies
15+
16+
...
17+
18+
## Layer Size
19+
20+
In `/opt/lib64/mysql`
21+
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
27+
```
28+
29+
30+
## Methodology
31+
32+
We used the `lambci/lambda:build-ruby2.5` Docker image from the [docker-lambda](https://github.com/lambci/docker-lambda) project.

‎bin/bootstrap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
docker -v $1 &> /dev/null
6+
7+
if [ $? -eq 0 ]; then
8+
echo "✅ Docker already installed."
9+
else
10+
echo "⚠️ DOCKER NOT INSTALLED! Please install Docker."
11+
exit 127
12+
fi

‎bin/build

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
export IMAGE_NAME=mysql2-lambda
6+
export MYSQL_VERSION=${MYSQL_VERSION:=0.5.3}
7+
8+
rm -rf ./share
9+
mkdir ./share
10+
11+
docker run \
12+
--rm \
13+
--volume "${PWD}/share:/share" \
14+
"${IMAGE_NAME}:latest" \
15+
sh -c "cp -r /build/share/* /share"
16+
17+
rm -rf ./gem && mkdir ./gem
18+
cp -r ./share/* ./gem
19+
cp ./README.md ./gem
20+
cp ./mysql2-lambda.gemspec ./gem
21+
22+
pushd ./gem
23+
24+
gem build mysql2-lambda.gemspec
25+
mv mysql2-lambda-* ../

‎bin/console

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
IMAGE_NAME=mysql2-lambda
6+
7+
docker run \
8+
--interactive \
9+
--tty \
10+
--rm \
11+
--volume "${PWD}:/var/task" \
12+
$IMAGE_NAME:latest \
13+
bash

‎bin/setup

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
export IMAGE_NAME=mysql2-lambda
6+
export MYSQL_VERSION=${MYSQL_VERSION:=0.5.3}
7+
8+
docker pull lambci/lambda:build-ruby2.5
9+
10+
docker build \
11+
--no-cache \
12+
--build-arg MYSQL_VERSION=${MYSQL_VERSION} \
13+
--tag $IMAGE_NAME \
14+
.

‎bin/update

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
./bin/setup

‎mysql2-lambda.gemspec

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Gem::Specification.new do |s|
2+
s.name = 'mysql2-lambda'
3+
s.version = '0.5.3.beta.1'
4+
s.authors = ['Ken Collins']
5+
s.license = "MIT"
6+
s.email = ['kcollins@customink.com']
7+
s.homepage = 'https://github.com/customink/mysql2-lambda'
8+
s.rdoc_options = ['--charset=UTF-8']
9+
s.summary = 'Precompiled Mysql2 gem for AWS Lambda using MariaDB.'
10+
s.metadata = {
11+
'bug_tracker_uri' => "#{s.homepage}/issues",
12+
'changelog_uri' => "#{s.homepage}/releases/tag/#{s.version}",
13+
'homepage_uri' => s.homepage,
14+
'source_code_uri' => "#{s.homepage}/tree/#{s.version}",
15+
}
16+
s.required_ruby_version = '>= 2.5.5'
17+
s.files = Dir.glob('./**/*')
18+
end

0 commit comments

Comments
 (0)
This repository has been archived.