2/12/2019

python zip test sample code


numberList = [1, 2, 3, 4, 5]
strList = ['one', 'two', 'three', 'five']

# No iterables are passed
result = zip()
print('first zip: {}'.format(result))

# Two iterables are passed
result = zip(numberList, strList)
print('input value to zip: {}'.format(result))

# Converting itertor to list
print('zip to list: {}'.format(list(result)))

# Converting itertor to set
resultSet = set(result)
print('zip to set: {}'.format(resultSet))



result


2/05/2019

How to install Node.js and npm on Amazon Linux (CentOS 7) for lambda


npm & node version check
> node --version
> npm --version


install or upgrade npm & node
Change setup_8.x, in case you want to install version 8.x
>curl -sL https://rpm.nodesource.com/setup_10.x | bash -
>yum install nodejs


If you already installed old version npm & node, remove first.
>yum remove -y nodejs npm


I have installed node as 8.x.

Enjoy!


2/04/2019

Install python 3.6 on AmazonLinux and make Docker image


Run Amazon Linux Container (and tunnelling)
> docker run -v $(pwd):/outputs --name lambdapack -d amazonlinux:latest tail -f /dev/null

Run container bash shell
> docker exec -i -t lambdapack /bin/bash
Install python 3.6
bash# yum -y update
bash# yum -y upgrade
bash# yum install -y \
 wget \
 gcc \
 gcc-c++ \
 findutils \
 zlib-devel \
 zip

bash# yum install -y yum-utils
bash# yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
bash# yum install -y python36.x86_64
bash# yum install -y python36-devel.x86_64
bash# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
bash# python36 get-pip.py
bash# pip3 install virtualenv
bash# exit

Make docker Image
> docker commit lambdapack marearts/amazon_linux_py36:v1.0.0

Push Docker Image to Docker Hub
>docker login
..
>docker push marearts/amazon_linux_py36:v1.0.0


Done!
Take Care!




1/29/2019

How to install wget in macOS?

install by brew
>ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
>brew install wget --with-libressl

install by port
> sudo port install wget


Enjoy!





1/28/2019

tar (child): xz: Cannot exec: No such file or directory on Amazon Linux

yum install -y xz

docker command summarise


stop all containers:
docker kill $(docker ps -q)

remove all containers
docker rm $(docker ps -a -q)

remove all docker images
docker rmi $(docker images -q)

access(enter) docker container
docker exec -it docker_container_name sh

Exit from docker container
>exit

Commit container and build image
docker commit container_name image_name
ex) docker commit lambdapack lambda_image
ex) docker commit lambdapack marearts/lambda_image:v1.0.0

Docker build
>docker build --tag hello:0.1 .
>docker build --tag marearts/hello:0.1 .

Docker run shell and tunnelling 
>docker run -v $(pwd):/outputs --name nickname -d docker_image tail -f /dev/null
ex)
>docker run -v $(pwd):/outputs --name lambdapackgen2 -d marearts/awspy:0.1 tail -f /dev/null

Docker run shell

> docker run -it marearts/amazon_linux_py36:v1.0.0 /bin/bash

Docker run sh file in container
>docker exec -i -t container_name /bin/bash /outputs/shfile.sh
ex)
>docker exec -i -t lambdapackgen2 /bin/bash /outputs/buildPack_py3.sh

Restart Docker container
>docker restart <container id or name>
ex)
docker restart 59



it will be updated..


1/27/2019

summarise Azure function docker image deploy



*make python virtualenv
*activate python virtualenv !!
*install azure util cli
https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image#run-the-build-command

make project (app)
func init DocApp100 --docker

change directory
cd DocApp100

new function
func new --name MyHttpTrigger --template "HttpTrigger"

build docker image
docker build --tag marearts/image:v1 .

make new resource group
az group create --name DocGroup --location westeurope

storage account
az storage account create --name docstorage100 --location westeurope --resource-group DocGroup --sku Standard_LRS

create linux service plan
az appservice plan create --name docserviceplan --resource-group DocGroup --sku B1 --is-linux

create app and deploy
az functionapp create --name docapp100 --storage-account docstorage100 --resource-group DocGroup --plan docserviceplan --deployment-container-image-name marearts/image:v1

Configuration the function app
storageConnectionString=$(az storage account show-connection-string --resource-group DocGroup --name docstorage100 --query connectionString --output tsv)
az functionapp config appsettings set --name docapp100 --resource-group DocGroup --settings AzureWebJobsDashboard=$storageConnectionString AzureWebJobsStorage=$storageConnectionString

Test
curl https://docapp100.azurewebsites.net/api/MyHttpTrigger?name=myname