SlideShare a Scribd company logo
MECAB IN DOCKERACTION!!!
USING DOCKERACTION OF IBM
CLOUD FUNCTIONS ( OPENWHISK )
2017.10.19 Bluemix User Group Tsukiji,Japan#1
ABOUT MYSELF
 (KUNITO Atsunori)
 Atsunori_kunito@niandc.co.jp
 I’m a Java programmer at NI and C Soft.inc.
 We are Nippon Information and Communication
Corporation Group.
1.MOTIVATION
MY PRIVATE PROJECT
 I was creating a personal tool which monitoring google
search ranking everyday. It works on Bluemix -
OpenWhisk.
 Next , I’d like to extract frequently appeared keyword
from the top 50 web pages.
 I wish I used Watson - Natural Language
Understanding(NLU). But the NLU doesn’t support
Japanese!!!
SOLUTION – WHAT IS MECAB?
 MeCab: Yet Another Part-of-Speech and Morphological
Analyzer(http://taku910.github.io/mecab/)
 MeCab is OSS which is created by Taku Kudo.
 Japanese has no separator(space) between word each
other.
 So I can count frequency of the words with the MeCab.
DOCKER ACTION
 MeCab is written in C++. How do I run this tool on
Cloud?
Docker Action !!!
wsk action update
wsk action invoke
/init Init process
Run MeCab/run
2.DOCKERACTION STEP BY STEP
Local
Bluemix - OpenWhisk
OVERVIEW
MeCab
MeCab
MeCabMeCab
exec
exec.zip
exec
STEP 1) Make Dockerfile
STEP 2) Push Docker image
STEP 3) Write entry point
STEP 4) Deploy exec
invoke
Docker Pull
STEP 1) MAKE DOCKERFILE
Key Learnings:
 Use ‘openwhisk/dockerskeleton’ as base image.
 Inject MeCab , dependencys and other tools(if needed) to
your docker image.
 Your docker image will be uploaded to
DockerHub(https://hub.docker.com/) and will be
PUBLIC. So You SHOULD NOT include private
informations. Be aware to password , API-key etc…
 Lunch actionproxy.py. It’s contained in
‘openwhisk/dockerskeleton’ .
DOCKERFILE
FROM openwhisk/dockerskeleton
RUN apk add --no-cache gcc libc-dev g++
RUN apk add --no-cache --virtual .build-deps git make ¥
&& apk add --no-cache libxml2-dev libxslt-dev
# install mecab
RUN cd /tmp && ¥
git clone https://github.com/taku910/mecab.git
RUN cd /tmp/mecab/mecab && ¥
./configure --enable-utf8-only && ¥
make && ¥
make install
RUN echo 'export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"' >> ~/.bashrc && ¥
. ~/.bashrc && ¥
cd /tmp/mecab/mecab-ipadic && ¥
./configure --with-charset=utf8 && ¥
make && ¥
make install
RUN pip install --no-cache-dir lxml
RUN pip install --no-cache-dir requests
RUN pip install --no-cache-dir beautifulsoup4
RUN apk del .build-deps
CMD ["/bin/bash", "-c", "cd actionProxy && python -u actionproxy.py"]
STEP 2) PUSH YOUR DOCKER IMAGE AND
CREATE ACTION
 Create an account in DockerHub(if you didn’t have it).
docker build -t openwhiskdatest/mecabda .
docker login
docker push openwhiskdatest/mecabda
bx wsk action create wskMeCabDH --docker openwhiskdatest/mecabda
STEP 3) WRITE AN ENTRY POINT OF YOUR
ACTION
 I wrote web crawler with Beautiful Soup and lxml in
python.
 Execute the MeCab.
 Make MeCab’s outputs into single-lined-JSON format. I
wrote this process in python too.
 Finally , I wrote BASH script which organize those
programs described above. This script must be named
‘exec’.
STEP 4) CREATE ZIP FILE AND DEPLOY IT
 Package programs described in step 3 into a zip file.
 Upload it to your action.
 Actionproxy.py receive the zip file. Then It extracts and
deploys contained programs.
bx wsk action update wskMeCabDH exec.zip --docker openwhiskdatest/mecabda
NOW WE CAN INVOKE DOCKER ACTION !!!
bx wsk action invoke wskMeCabDH --blocking --result -p "url" https://bmxug.connpass.com/event/66961/
IT WORKS ON MY PROJECT
 Google search word is ‘OpenWhisk’.
 Crawling top 50 web pages.
 Extract frequently appeared keyword.
 It’s represented with wordcloud2 in R.
 Can you read ‘Lambda’?
It shows many sites about Openwhisk
compare with Lambda , I guess.
3.CONCLUSION
CONCLUSION
Key Learnings:
 Docker Action is great way to execute some binaries on
Bluemix.
 Every Openwhisk actions are implemented on Docker
Action. In other words , Action Runtime is a pre-defined
Docker Action for specific programming language.
USECASE OF DOCKER ACTION
 Execute some binaries or shell scripts on Bluemix, of
course.
 You can create your runtime which supports your
favorite programing language.
 If you wanted to use some dependencies which are
unsupported in runtime , You can create a dockerfile to
inject those dependencies.
REFERENCES
 https://hub.docker.com/r/openwhisk/spellcheck/
 https://www.ibm.com/blogs/bluemix/2017/01/dock
er-bluemix-openwhisk/
 http://jamesthom.as/blog/2017/01/16/openwhisk-
docker-actions/
 DockerHub
 https://hub.docker.com/r/openwhisk/dockerskeleton/
 https://www.niandc.co.jp/sol/tech/date20170626_6
98.php
Thank you !!!

More Related Content

PDF
Docker for Artisans
PDF
Hudson and Drupal
PDF
Deploying a Pylons app to Google App Engine
PDF
Mastering xPaaS - get down and dirty in the OpenShift Cloud (part I)
PDF
Docker, Ansible and Symfony micro-kernel
PPTX
DevOps: Docker Workshop
PDF
Composer and deployer for enterprise
PPT
Preparing Cappuccino in 30 minutes
Docker for Artisans
Hudson and Drupal
Deploying a Pylons app to Google App Engine
Mastering xPaaS - get down and dirty in the OpenShift Cloud (part I)
Docker, Ansible and Symfony micro-kernel
DevOps: Docker Workshop
Composer and deployer for enterprise
Preparing Cappuccino in 30 minutes

What's hot (20)

PDF
Workshop - Golang language
PDF
OpenShift State of the Union, brought to you by JBoss
PDF
Introduction to Express and Grunt
PDF
Plone and docker
PPTX
Bringing Javascript to the Desktop with Electron
PPTX
Development with Vagrant
PPTX
Docker & Kubernetes
PDF
Docker and plone
PPTX
Grunt - The JavaScript Task Runner
PDF
Docker, developers take power
PDF
Docker: from zero to nonzero
PDF
2016 may-31 dockercon2016–cool-hackssubmission
PDF
Production Ready Javascript With Grunt
ODP
What grunt?
PDF
CoffeeScript in 5mins
PDF
Ratpack On the Docks
PDF
Groovy Powered Clean Code
PDF
Bower & Grunt - A practical workflow
PDF
Grunt JS - Getting Started With Grunt
PDF
Docker & FieldAware
Workshop - Golang language
OpenShift State of the Union, brought to you by JBoss
Introduction to Express and Grunt
Plone and docker
Bringing Javascript to the Desktop with Electron
Development with Vagrant
Docker & Kubernetes
Docker and plone
Grunt - The JavaScript Task Runner
Docker, developers take power
Docker: from zero to nonzero
2016 may-31 dockercon2016–cool-hackssubmission
Production Ready Javascript With Grunt
What grunt?
CoffeeScript in 5mins
Ratpack On the Docks
Groovy Powered Clean Code
Bower & Grunt - A practical workflow
Grunt JS - Getting Started With Grunt
Docker & FieldAware
Ad

Similar to MeCab in docker action(OpenWhisk) (20)

PDF
Docker 1.9 Workshop
PDF
Testing with Docker
PDF
How abusing the Docker API led to remote code execution same origin bypass an...
PPTX
Duke Docker Day 2014: Research Applications with Docker
PDF
Docker workshop
PPTX
Rexdockercon2017
PDF
Docker for developers on mac and windows
PDF
Keep it simple web development stack
PPTX
Dockerfile Basics | Docker workshop #2 at twitter, 2013-11-05
PDF
Into The Box 2018 Going live with commandbox and docker
PDF
Going live with BommandBox and docker Into The Box 2018
PPTX
Dockerfile at Guidewire
PDF
Docker - introduction
PPTX
Dockerfile Basics Workshop #2
PDF
Using docker for data science - part 2
PDF
Hack the whale
PPTX
Docker and the Container Ecosystem
PDF
How to create your own hack environment
PDF
Workshop : 45 minutes pour comprendre Docker avec Jérôme Petazzoni
PDF
Introduction to Docker, December 2014 "Tour de France" Edition
Docker 1.9 Workshop
Testing with Docker
How abusing the Docker API led to remote code execution same origin bypass an...
Duke Docker Day 2014: Research Applications with Docker
Docker workshop
Rexdockercon2017
Docker for developers on mac and windows
Keep it simple web development stack
Dockerfile Basics | Docker workshop #2 at twitter, 2013-11-05
Into The Box 2018 Going live with commandbox and docker
Going live with BommandBox and docker Into The Box 2018
Dockerfile at Guidewire
Docker - introduction
Dockerfile Basics Workshop #2
Using docker for data science - part 2
Hack the whale
Docker and the Container Ecosystem
How to create your own hack environment
Workshop : 45 minutes pour comprendre Docker avec Jérôme Petazzoni
Introduction to Docker, December 2014 "Tour de France" Edition
Ad

Recently uploaded (20)

PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
NewMind AI Weekly Chronicles - August'25 Week I
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
KodekX | Application Modernization Development
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Big Data Technologies - Introduction.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Spectroscopy.pptx food analysis technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Unlocking AI with Model Context Protocol (MCP)
Diabetes mellitus diagnosis method based random forest with bat algorithm
NewMind AI Weekly Chronicles - August'25 Week I
The AUB Centre for AI in Media Proposal.docx
Spectral efficient network and resource selection model in 5G networks
Understanding_Digital_Forensics_Presentation.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Per capita expenditure prediction using model stacking based on satellite ima...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Programs and apps: productivity, graphics, security and other tools
KodekX | Application Modernization Development
Reach Out and Touch Someone: Haptics and Empathic Computing
Big Data Technologies - Introduction.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Chapter 3 Spatial Domain Image Processing.pdf
Network Security Unit 5.pdf for BCA BBA.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Spectroscopy.pptx food analysis technology

MeCab in docker action(OpenWhisk)

  • 1. MECAB IN DOCKERACTION!!! USING DOCKERACTION OF IBM CLOUD FUNCTIONS ( OPENWHISK ) 2017.10.19 Bluemix User Group Tsukiji,Japan#1
  • 2. ABOUT MYSELF  (KUNITO Atsunori)  Atsunori_kunito@niandc.co.jp  I’m a Java programmer at NI and C Soft.inc.  We are Nippon Information and Communication Corporation Group.
  • 4. MY PRIVATE PROJECT  I was creating a personal tool which monitoring google search ranking everyday. It works on Bluemix - OpenWhisk.  Next , I’d like to extract frequently appeared keyword from the top 50 web pages.  I wish I used Watson - Natural Language Understanding(NLU). But the NLU doesn’t support Japanese!!!
  • 5. SOLUTION – WHAT IS MECAB?  MeCab: Yet Another Part-of-Speech and Morphological Analyzer(http://taku910.github.io/mecab/)  MeCab is OSS which is created by Taku Kudo.  Japanese has no separator(space) between word each other.  So I can count frequency of the words with the MeCab.
  • 6. DOCKER ACTION  MeCab is written in C++. How do I run this tool on Cloud? Docker Action !!! wsk action update wsk action invoke /init Init process Run MeCab/run
  • 8. Local Bluemix - OpenWhisk OVERVIEW MeCab MeCab MeCabMeCab exec exec.zip exec STEP 1) Make Dockerfile STEP 2) Push Docker image STEP 3) Write entry point STEP 4) Deploy exec invoke Docker Pull
  • 9. STEP 1) MAKE DOCKERFILE Key Learnings:  Use ‘openwhisk/dockerskeleton’ as base image.  Inject MeCab , dependencys and other tools(if needed) to your docker image.  Your docker image will be uploaded to DockerHub(https://hub.docker.com/) and will be PUBLIC. So You SHOULD NOT include private informations. Be aware to password , API-key etc…  Lunch actionproxy.py. It’s contained in ‘openwhisk/dockerskeleton’ .
  • 10. DOCKERFILE FROM openwhisk/dockerskeleton RUN apk add --no-cache gcc libc-dev g++ RUN apk add --no-cache --virtual .build-deps git make ¥ && apk add --no-cache libxml2-dev libxslt-dev # install mecab RUN cd /tmp && ¥ git clone https://github.com/taku910/mecab.git RUN cd /tmp/mecab/mecab && ¥ ./configure --enable-utf8-only && ¥ make && ¥ make install RUN echo 'export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"' >> ~/.bashrc && ¥ . ~/.bashrc && ¥ cd /tmp/mecab/mecab-ipadic && ¥ ./configure --with-charset=utf8 && ¥ make && ¥ make install RUN pip install --no-cache-dir lxml RUN pip install --no-cache-dir requests RUN pip install --no-cache-dir beautifulsoup4 RUN apk del .build-deps CMD ["/bin/bash", "-c", "cd actionProxy && python -u actionproxy.py"]
  • 11. STEP 2) PUSH YOUR DOCKER IMAGE AND CREATE ACTION  Create an account in DockerHub(if you didn’t have it). docker build -t openwhiskdatest/mecabda . docker login docker push openwhiskdatest/mecabda bx wsk action create wskMeCabDH --docker openwhiskdatest/mecabda
  • 12. STEP 3) WRITE AN ENTRY POINT OF YOUR ACTION  I wrote web crawler with Beautiful Soup and lxml in python.  Execute the MeCab.  Make MeCab’s outputs into single-lined-JSON format. I wrote this process in python too.  Finally , I wrote BASH script which organize those programs described above. This script must be named ‘exec’.
  • 13. STEP 4) CREATE ZIP FILE AND DEPLOY IT  Package programs described in step 3 into a zip file.  Upload it to your action.  Actionproxy.py receive the zip file. Then It extracts and deploys contained programs. bx wsk action update wskMeCabDH exec.zip --docker openwhiskdatest/mecabda
  • 14. NOW WE CAN INVOKE DOCKER ACTION !!! bx wsk action invoke wskMeCabDH --blocking --result -p "url" https://bmxug.connpass.com/event/66961/
  • 15. IT WORKS ON MY PROJECT  Google search word is ‘OpenWhisk’.  Crawling top 50 web pages.  Extract frequently appeared keyword.  It’s represented with wordcloud2 in R.  Can you read ‘Lambda’? It shows many sites about Openwhisk compare with Lambda , I guess.
  • 17. CONCLUSION Key Learnings:  Docker Action is great way to execute some binaries on Bluemix.  Every Openwhisk actions are implemented on Docker Action. In other words , Action Runtime is a pre-defined Docker Action for specific programming language.
  • 18. USECASE OF DOCKER ACTION  Execute some binaries or shell scripts on Bluemix, of course.  You can create your runtime which supports your favorite programing language.  If you wanted to use some dependencies which are unsupported in runtime , You can create a dockerfile to inject those dependencies.
  • 19. REFERENCES  https://hub.docker.com/r/openwhisk/spellcheck/  https://www.ibm.com/blogs/bluemix/2017/01/dock er-bluemix-openwhisk/  http://jamesthom.as/blog/2017/01/16/openwhisk- docker-actions/  DockerHub  https://hub.docker.com/r/openwhisk/dockerskeleton/  https://www.niandc.co.jp/sol/tech/date20170626_6 98.php