Ruby on Jets Verification (WSL)

Introduction

This article summarizes the verification of "Jets", a serverless framework made by Ruby. The environment is Windows 10, but I am using WSL (Debian) because Jets does not work on Windows.

Purpose

The purpose of this time is to guarantee the operation of DynamoDB table design and data access design.

Environment

List the commands executed when the environment was actually built.

WSL Install WSL (Ubuntu or Debian) from the Windows Store.

sudo apt update
sudo apt upgrade
sudo apt install -y make gcc libssl-dev libreadline-dev zlib1g-dev git curl wget unzip

Ruby See the Ruby part of the article below https://qiita.com/ksh-fthr/items/64a4e86c8bad08322c94#3-rbenv-%E3%82%92%E5%85%A5%E3%82%8C%E3%82%88%E3%81%86

git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
~/.rbenv/bin/rbenv init
vi .bashrc
source ~/.bashrc
rbenv install -l
rbenv install 2.6.6
rbenv rehash
rbenv global 2.6.6
ruby -v

Jets https://qiita.com/gotchane/items/fd3c1e54f7bdaa4ab813

sudo apt install -y nodejs npm
sudo npm install -g yarn
gem install jets
jets new project name

dynamodb local https://symfoware.blog.fc2.com/blog-entry-2207.html

sudo apt install openjdk-11-jre
wget https://s3-ap-northeast-1.amazonaws.com/dynamodb-local-tokyo/dynamodb_local_latest.tar.gz
mkdir dynamodb
tar zxf dynamodb_local_latest.tar.gz -C ./dynamodb
cd dynamodb/
java -D"java.library.path=./DynamoDBLocal_lib" -jar DynamoDBLocal.jar -sharedDb

dynamodb-admin https://www.npmjs.com/package/dynamodb-admin

npm install -g dynamodb-admin
export DYNAMO_ENDPOINT=http://localhost:8000
dynamodb-admin

aws-cli https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/install-cliv2-linux.html

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
/usr/local/bin/aws --version
aws configure
→ Appropriate key in CUI,set id(test_id, test_key etc.)
aws dynamodb list-tables --endpoint-url http://localhost:8000
→ Check connection

Environment construction is over

Jets verification

The following articles were very helpful in verifying Jets, which has little information. https://qiita.com/gotchane/items/fd3c1e54f7bdaa4ab813 https://qiita.com/gotchane/items/d998b49dcaa31fe286b9 https://qiita.com/gotchane/items/b412295bee48ba827715

Setting

--Changed table_namespace in config/dynamodb.yml --table_namespace: ○○○○ (project name, etc.)

Create table

--Created by dynamodb-admin --It is necessary to create the model described later. --For how to create a table with dynamodb-admin, please refer to the previously written this article. --Created by Jets migration - https://rubyonjets.com/reference/jets-dynamodb-generate/ --Example: jets dynamodb: generate create_users --partition-key user_id: string --sort-key delete_flg: number

Creating a model

When creating a table with dyanamodb-admin, create a model of the created table with the following contents. Example: When the Users table is created, create the "user.rb" file under app/models.

class model name(User etc.) < Dynomite::Item
end

Data manipulation with Jets console

--Execute "jets c" in the project directory to start the console -Create a query by referring to dynomite

create_user = User.new(user_id: "test1_name", user_name: "test1", user_email: "[email protected]", delete_flg: 0)
create_user.replace
User.find(user_id:"test1_name", delete_flg:0)

Other

Addictive point (memo)

--As described in the section on creating a table, Jets migration, in which a migration file is created, is ideal for creating a table. However, with the current amount of Jets information, an appropriate method for setting GSI and LSI could not be found at once. ――It is best to set GSI and LSI based on the data access design, but it may be necessary to change it depending on the situation. In that case, if you use dynamod b-admin, you need to recreate the table. --The Jets file running on WSL was operated with VScode started on Windows. --Please refer to here etc. for the procedure such as installing RemoteWSL.

error

I couldn't test the migration with a mysql2 gem error in my environment. I solved it with the following command.

gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'

Reference article

Official: https://rubyonjets.com/ https://qiita.com/gotchane/items/fd3c1e54f7bdaa4ab813 https://qiita.com/gotchane/items/d998b49dcaa31fe286b9 https://qiita.com/gotchane/items/b412295bee48ba827715

in conclusion

Since Ruby on Jets was created by AWS container HERO, an AWS specialist with only about 5 people in the world, I felt that it was highly reliable and functional. However, since it is currently maintained by almost one person, it is necessary to carefully judge the application to the production environment. If you are interested, please see the following article. https://qiita.com/gotchane/items/02b9c539bfaf3a69d76e

We would like to thank @gotchane for compiling many Jets articles.

Recommended Posts

Ruby on Jets Verification (WSL)
Ruby installation on WSL2 + Ubuntu 20.04
Ruby on Rails Elementary
Ruby on Rails basics
Ruby On Rails Association
ubuntu on wsl part 10
Docker installation on WSL2
Ruby on rails learning record -2020.10.03
Portfolio creation Ruby on Rails
Ruby on rails learning record -2020.10.04
[Ruby on Rails] Debug (binding.pry)
Ruby on rails learning record -2020.10.05
Ruby on rails learning record -2020.10.09
Ruby on Rails config configuration
[Ruby on Rails] about has_secure_password
Commentary on partial! --Ruby on Rails
Install Ruby 2.7 on RHEL 8 (AppStream)
Ruby on rails learning record-2020.10.07 ①
Cancel Ruby on Rails migration
Install Ruby 2.7 on CentOS 7 (SCL)
I tried Jets (ruby serverless)
Ruby on Rails validation summary
Ruby on Rails Basic Memorandum
Install Ruby on Sakura's VPS
Ruby on Rails --From environment construction to simple application development on WSL2
From building to deploying Ruby on Jets in docker-compose environment <Part 2>
From building to deploying Ruby on Jets in docker-compose environment <Part 1>
Install Ruby on MSYS2 with pacman
Ruby on Rails Overview (Beginner Summary)
[Ruby on Rails] Read try (: [],: key)
[Ruby on Rails] yarn install --check-files
Ruby on Rails variable, constant summary
Installing Ruby + Rails on Ubuntu 18.04 (rbenv)
[Ruby on Rails] Introduced paging function
Basic knowledge of Ruby on Rails
Progate Ruby on Rails5 Looking Back
Install Ruby 2.5 on CentOS 7 using SCL
How to use Ruby on Rails
[Ruby on Rails] Add / Remove Columns
(Ruby on Rails6) "Erase" posted content
Ruby on Rails 6.0 environment construction memo
[Ruby on Rails] What is Bcrypt?
[Ruby on Rails] Confirmation page creation
Ruby On Rails devise routing conflict
[Ruby on Rails] Comment function implementation
Elmer / Ice installation (Ubuntu on WSL)
[Ruby on Rails] Convenient helper method
Using Docker on Windows10 Home WSL2
Install ruby on Ubuntu 20.04 with rbenv
[Ruby on Rails] Stop "looping until ..."