Python Project Deployment 템플릿

|

Python 프로젝트 배포

Docker Image를 이용해서 배포하는 경우와 Git 소스 코드를 이용해서 배포하는 yaml 코드 예제입니다.

사용방법은 예시는 다음과 같습니다.

$ oc create -f deployment-using-docker-image.yaml

$ oc create -f deployment-using-git.yaml


전체 코드는 GitHub에서 확인할 수 있습니다.

Dockerfile

FROM ubuntu

# basic setting for python
RUN apt-get update
RUN apt-get install -y python python-pip


# install my app
WORKDIR /app

COPY . .

RUN pip install --upgrade pip
RUN pip install -r requirements.txt

# expose ports
EXPOSE 8080


## launch
CMD [ "python", "./app/server.py" ]


deployment-using-docker-image.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: python-sample
  labels:
    app: python-sample
spec:
  template:
    metadata:
      labels:
        app: python-sample
    spec:
      containers:
      - image:  snowdeer/python-sample:latest
        name: python-sample
        ports:
        - containerPort: 8080
          protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  name: python-sample
  labels:
    app: python-sample
spec:
  ports:
  - name: python-sample
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: python-sample
  type: LoadBalancer
---
apiVersion: v1
kind: Route
metadata:
  name: python-sample
  labels:
    app: python-sample
spec:
  port: 
    targetPort: python-sample
  to:
    kind: Service
    name: python-sample
    weight: 100


deployment-using-git.yaml

apiVersion: v1
kind: BuildConfig
metadata:
  labels:
    app: python-sample
  name: python-sample
spec:
  failedBuildsHistoryLimit: 3
  nodeSelector: null
  postCommit: {}
  resources: {}
  runPolicy: Serial
  source:
    git:
      uri: 'https://github.com/snowdeer/openshift-python-sample.git'
    type: Git
  strategy:
    dockerStrategy:
      from:
        kind: DockerImage
        name: 'ubuntu:latest'
        
    type: Docker    
  successfulBuildsHistoryLimit: 5 
  output:
    to:
      kind: ImageStreamTag
      name: 'python-sample:latest'
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: python-sample
  labels:
    app: python-sample
spec:
  template:
    metadata:
      labels:
        app: python-sample
    spec:
      containers:
      - image:  snowdeer/python-sample:latest
        name: python-sample
        ports:
        - containerPort: 8080
          protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  name: python-sample
  labels:
    app: python-sample
spec:
  ports:
  - name: python-sample
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: python-sample
  type: LoadBalancer
---
apiVersion: v1
kind: Route
metadata:
  name: python-sample
  labels:
    app: python-sample
spec:
  port: 
    targetPort: python-sample
  to:
    kind: Service
    name: python-sample
    weight: 100

Hello. World Sample

|

Hello Node.js

package.json

{
  "name": "hello",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
  "test": "echo \"Error: no test specified\"exit 1",
  "start": "node app.js"
},
  "author": "",
  "license": "Apache",
  "dependencies": {
    "express": "^4.16.2"
  }
}


app.js

var port = 8080;

var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.send('This is an index page.');
});

app.get('/hello', function (req, res) {
  res.send('Hello World!');
});

app.listen(port, function () {
  console.log('Example app is listening on port ', port);
});

Ubuntu 18.04에 Libre Office 수동으로 설치하는 방법

|

Ubuntu 18.04에 Libre Office 수동으로 설치하는 방법

sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update
sudo apt-get install libreoffice


삭제 방법

sudo apt-get remove libreoffice-core
sudo apt-get remove --purge libreoffice-core

OpenShift Cluster UP/DOWN 스크립트(AWS 기준)

|

OpenShift Cluster UP/DOWN

AWS가 아닌 다른 서버에서 OpenShift의 클러스터(Cluster)를 UP/DOWN 시킬 때는 단순히

$ oc cluster up

$ oc cluster down

명령어만 사용하면 됩니다.

AWS에서 클러스터 UP을 하기 위해서는 다음 스크립트를 실행하면 됩니다.

metadata_endpoint="http://169.254.169.254/latest/meta-data"

public_hostname="$( curl "${metadata_endpoint}/public-hostname" )"

public_ip="$( curl "${metadata_endpoint}/public-ipv4" )"

oc cluster up --public-hostname="${public_hostname}" --routing-suffix="${public_ip}.nip.io"

클러스터 Down 명령어는 동일합니다.

Material Pallete

|

Material Pallete

Material Design을 위한 색상 팔레트 및 아이콘 등을 제공해주는 사이트입니다.

여기에서 확인할 수 있습니다.


Flutter Color Palettes

Flutter에서도 Material Color Palette를 제공하고 있습니다. 예를 들면, 제가 개인적으로 좋아하는 teal 색상에 대한 팔레트는

https://api.flutter.dev/flutter/material/Colors/teal-constant.html

에서 확인할 수 있습니다.