一,基础镜像

【xxx.com.cn/3rd_part/python.3.6.8:alpine3.9-mysqlclient1.4.2】

FROM python:3.6.8-alpine3.7
MAINTAINER Takuya Noguchi <takninnovationresearch@gmail.com>

RUN apk add --update --no-cache mariadb-client-libs \
    && apk add --no-cache --virtual .build-deps \
        mariadb-dev \
        gcc \
        musl-dev \
    && pip install mysqlclient==1.4.2 \
    && apk del .build-deps

二,中间件镜像

【xxx.com.cn/xxx-4k:base-0.4】

FROM xxx.com.cn/3rd_part/python.3.6.8:alpine3.9-mysqlclient1.4.2

MAINTAINER xxx-4K

COPY requests.txt /tmp/requests.txt
COPY kubectl /docker/home/docker/bin/kubectl14
COPY cx_Oracle-7.2.2-cp36-cp36m-linux_x86_64.whl /tmp/cx_Oracle-7.2.2-cp36-cp36m-linux_x86_64.whl
COPY Pillow-5.4.1-cp36-cp36m-linux_x86_64.whl /tmp/Pillow-5.4.1-cp36-cp36m-linux_x86_64.whl
COPY pycryptodome-3.9.0-cp36-cp36m-linux_x86_64.whl /tmp/pycryptodome-3.9.0-cp36-cp36m-linux_x86_64.whl

RUN  pip install -r /tmp/requests.txt  \
    && pip install /tmp/cx_Oracle-7.2.2-cp36-cp36m-linux_x86_64.whl\
    && pip install /tmp/Pillow-5.4.1-cp36-cp36m-linux_x86_64.whl\
    && pip install /tmp/pycryptodome-3.9.0-cp36-cp36m-linux_x86_64.whl\
    && chmod 755 /docker/home/docker/bin/kubectl14  \
    && ln -s /docker/home/docker/bin/kubectl14 /usr/local/bin/kubectl \
    && rm -rf ~/.cache/* \
    && rm -rf /tmp/* \
    && echo 'finished!!!'

requirementes.txt

amqp==2.2.2
Babel==2.1.1
billiard==3.5.0.3
celery==4.1.0
certifi==2017.11.5
chardet==3.0.4
Django==2.0
django-cors-headers==2.4.0
django-redis==4.8.0
django-tinymce==2.7.0
django-widget-tweaks==1.4.3
djangorestframework==3.7.3
flower==0.9.2
gunicorn==19.6.0
idna==2.6
IPy==0.83
kafka-python==1.4.3
kombu==4.1.0
multi-key-dict==2.0.3
pbr==3.1.1
PyMySQL==0.8.0
python-jenkins==1.4.0
pytz==2017.3
PyYAML==3.13
redis==2.10.6
requests==2.18.4
setuptools-git==1.2
six==1.11.0
sqlparse==0.3.0
tornado==5.1
urllib3==1.22
vine==1.1.4
xlrd==1.1.0
xlwt==1.3.0

三,业务镜像

【xxx.com.cn/itil/itil-4k-gunicorn:K8S-20191018184523MP】

FROM xxx.com.cn/xxx-4k:base-0.4

COPY 4k.zip /4k/temp/4k.zip
COPY bootstart.sh  /xxx/bootstart.sh

CMD sh  /xxx/bootstart.sh

[bootstart.sh]

#!/bin/bash

zip_dir="/xxx/temp"

zip_file=`ls $zip_dir/*.zip`
mkdir $zip_dir/deploy_temp
unzip $zip_file -d   $zip_dir/deploy_temp

mkdir -p /apps/xxx

cp -ar $zip_dir/deploy_temp/xxx/ /apps/xxx/

cd /apps/xxx/
sh start_gunicorn_k8s.sh
[start_gunicorn_k8s.sh]
gunicorn -c gunicorn_k8s.ini 4K.wsgi

[gunicorn_k8s.ini]

bind = "0.0.0.0:9123"
workers = 4
errorlog = './gunicorn.error.log'
accesslog = './gunicorn.access.log'
timeout = 3000
loglevel = 'debug'
proc_name = 'gunicorn_proc'
access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"'
worker_connections = 1000
max_requests = 2000
graceful_timeout = 300
loglevel = 'debug'
daemon = 'false'
[wsgi]
"""
WSGI config for 4K project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "4K.settings.prd")

application = get_wsgi_application()

四,YAML文件

---
apiVersion: v1
kind: Service
metadata:
  labels:
    name: 4k-gunicorn
  name: 4k-gunicorn
  namespace: default
spec:
  ports:
  - port: 9090
    targetPort: 9123
  selector:
    name: 4k-gunicorn
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: 4k-gunicorn
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      name: 4k-gunicorn
  template:
    metadata:
      labels:
        name: 4k-gunicorn
    spec:
      imagePullSecrets:
      - name: 4kharbor
      containers:
      - name: 4k-gunicorn
        image: xxx.com.cn/itil/itil-4k-gunicorn:K8S-20191018453216MP
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9123

线上可用django和gunicorn的dockerfile内容的更多相关文章

  1. 在nginx上部署django项目--------Gunicorn+Django+nginx+mysql

    一.安装nginx 以前的博客我有写,这里就不写了 http://www.cnblogs.com/wt11/p/6420442.html 二.安装mysql 我用的mysql5.7  64位的二进制包 ...

  2. 一次线上OOM故障排查经过

    转贴:http://my.oschina.net/flashsword/blog/205266 本文是一次线上OOM故障排查的经过,内容比较基础但是真实,主要是记录一下,没有OOM排查经验的同学也可以 ...

  3. Django线上部署教程:腾讯云+Ubuntu+Django+Uwsgi(转载)

    网站名称: 向东的笔记本 本文链接: https://www.eastnotes.com/post/29 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议.转载请注明出处! ...

  4. 线上Django项目python2到3升级日记

    这两天干了一个几斤疯狂的事情,花不到一个工作日的时间把一个线上Django项目语言版本从python2升级到Python31.字典的一个语法变化 Python2.7: if dict1.haskey( ...

  5. 记录线上与本地docker镜像一致,但Dockerfile却构建失败的问题

    背景 公司新开了某个项目,我在新的服务器部署了docker环境,本着ctrl+c 和ctrl+v的惯例,直接把以前的php环境的Dockerfile文件直接复制到新项目服务器那里,结果构建失败,失败的 ...

  6. Django线上部署代码修改失效问题

    记一次django项目的线上部署维护问题,django+nginx 关于nginx反向代理服务器的介绍这里有一篇博客介绍的比较好:nginx的相关介绍 以及当一次客户端请求发出后,uwsig以及uWS ...

  7. Arthas协助排查线上skywalking不可用问题

    前言 首先描述下问题的背景,博主有个习惯,每天上下班的时候看下skywalking的trace页面的error情况.但是某天突然发现生产环境skywalking页面没有任何数据了,页面也没有显示任何的 ...

  8. Django (auth模块、User对象、用户认证、线上-用户认证)

    一.auth模块 django.contrib.auth中提供了许多方法,这里主要介绍其中的三个: authenticate()    提供了用户认证,即验证用户名以及密码是否正确,一般需要usern ...

  9. 分布式存储 FastDFS-5.0.5线上搭建

    前言:       由于公司项目需要,最近开始学习一下分布式存储相关知识,确定使用FastDFS这个开源工具.学习之初,自己利用VMware虚拟机搭建了一个5台机器的集群,摸清了安装过程中可能出现的问 ...

随机推荐

  1. linux学习(七)Shell编程中的变量

    目录 shell编程的建立 shell的hello world! Shell的环境变量 使用和设置环境变量 Shell的系统变量 用户自定义变量 @(Shell编程) shell编程的建立 [root ...

  2. ORACLE EXPIRED(GRACE)

    查询用户状态col username for a20col account_status for a20select username,account_status,LOCK_DATE,EXPIRY_ ...

  3. MySQL 数据库查询数据,过滤重复数据保留一条数据---(MySQL中的row_number变相实现方法)

    转自: http://www.maomao365.com/?p=10564 摘要: 下文讲述MySQL数据库查询重复数据时,只保留一条数据的方法 实现思路: 在MySQL数据库中没有row_numbe ...

  4. docker 私有registry harbor安装

    一,harbor安装: 参考:Installation and Configuration Guide 1,安装docker 2,安装docker compose sudo curl -L " ...

  5. Young and Beautiful 新红楼剪辑(by up)

    up剪辑的新红楼视频,配上Young and Beautiful 这首英文歌,很优美^_^

  6. SSH整合二

    结构图 articles模块 实体类Articles.java package com.jt.articles.entity; public class Articles { private Inte ...

  7. 「MacOS」将网站转换为应用程序,只需一个Unite

    unite mac有着非常强大的功能,能够轻松的将网站转换为macOS上的应用程序,除了现代化的网页浏览功能以外,Unite for Mac下载还包括特定于macOS的功能,通知,TouchBar支持 ...

  8. echarts常用说明

    import { Injectable } from '@angular/core'; //模板option通用 let fff7 = '#fff'; //字体统一颜色rgba(255,255,255 ...

  9. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) E. Arson In Berland Forest 二分 前缀和

    E. Arson In Berland Forest The Berland Forest can be represented as an infinite cell plane. Every ce ...

  10. Codeforces Round #599 (Div. 2) B2. Character Swap (Hard Version) 构造

    B2. Character Swap (Hard Version) This problem is different from the easy version. In this version U ...