A multifunctional image based on Ubuntu 16.04

Time:2021-12-8

1、 Write in front

We like the convenience of docker, but some can meet our requirements. Some are not satisfied, so I packaged some functions into a docker image based on Ubuntu 16.04. The image containsphp7.1 composer npm cnpm nodejs supervisor nginx yarn python3 caddyIt also contains PHP extensionsmongoredisIt also contains some commonly used lib libraries.

thinking

First, you need to have a basic image, the so-called base image, which is based on Ubuntu 16.04. And it integrates some common lib libraries. Then we install some tools we need on the base image.

2、 Base image

Here is the dockerfile

FROM       ubuntu:16.04
MAINTAINER siya Lai <[email protected]> <[email protected]>

ENV DEBIAN_FRONTEND=noninteractive
RUN sed -i [email protected]/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list

RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y software-properties-common python-software-properties && LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php && \
    apt-get install -y apt-transport-https zip mcrypt && \
    apt-get install -y libpq-dev libfreetype6-dev libpng12-dev libmcrypt-dev && \
    apt-get install -y libcurl4-openssl-dev pkg-config libssl-dev openssh-server vim libncurses5-dev && \
    apt-get install -y ncurses-dev libreadline6-dev lua5.1-0-dev ruby ruby-dev python-dev libyaml-cpp-dev zlib1g.dev && \
    apt-get install -y curl tzdata && \
    apt-get install -y language-pack-zh-hant-base language-pack-zh-hans-base
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'root:root' |chpasswd

RUN sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config

RUN echo "set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1" >> ~/.vimrc && \
    echo "set termencoding=utf-8" >> ~/.vimrc && \
    echo "set fileformats=unix" >> ~/.vimrc && \
    echo "set encoding=prc" >> ~/.vimrc

RUN echo "alias vi=vim" >> ~/.bashrc
RUN mkdir -p ~/.vim/bundle/vim-go ~/.vim/bundle/Vundle.vim
ADD vim-go /root/.vim/bundle/vim-go
ADD Vundle.vim /root/.vim/bundle/Vundle.vim
WORKDIR /data
ADD Dockerfile /data
RUN mkdir -p /var/run/sshd

RUN apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

EXPOSE 22

The dockerfile, based on Ubuntu 16.04, installs some lib libraries and common tools, such as sshd. It also replaces the Ubuntu source with Ali’s image source.
Package the basic image into an image and upload it to dockerhub.
Docker image name issiya/ubuntu16.04-vim-ssh

3、 Base image based installation tool

Based on the abovesiya/ubuntu16.04-vim-ssh, building.

FROM siya/ubuntu16.04-vim-ssh
MAINTAINER siya Lai <[email protected]> <[email protected]>

ADD Dockerfile /data
RUN apt-get update
RUN apt-get install -y nginx git cron supervisor
RUN apt-get install -y php7.1 php7.1-common php7.1-fpm php7.1-dev && \
    apt-get install -y php7.1-mbstring php7.1-xml php7.1-gd php7.1-exif php7.1-zip php7.1-iconv php7.1-mcrypt  && \
    apt-get install -y php-redis php-mongodb php7.1-pgsql php7.1-mysql && \
    apt-get install -y librabbitmq-dev && \
    apt-get install -y php-amqp && \
    rm -rf /tmp/* && \
    rm -rf /var/lib/apt/lists/*
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
    apt-get update && \
    apt-get install -y nodejs && \
    apt-get install -y yarn && \
    npm install -g cnpm --registry=https://registry.npm.taobao.org && \
    php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" && \
    php composer-setup.php && \
    php -r "unlink('composer-setup.php');" && \
    mv composer.phar /bin/composer && \
    composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ && \
    composer global require "fxp/composer-asset-plugin:^1.3.1" -vvv && \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
    rm -rf /tmp/* && \
    rm -rf /var/lib/apt/lists/*

RUN wget -qO- https://getcaddy.com | bash -s personal

RUN mkdir -p /data/src && cd /data/src && \
    wget https://dl.google.com/go/go1.12.6.linux-amd64.tar.gz && tar -zxvf go1.12.6.linux-amd64.tar.gz

RUN ln -f /data/src/go/bin/go /usr/local/bin/go && ln -f /data/src/go/bin/gofmt /usr/local/bin/gofmt && ln -f /data/src/go/bin/godoc /usr/local/bin/godoc && \
    export GOROOT=/data/src/go && export GOPATH=/data/src/ && echo "PATH=$PATH:/usr/local/bin" >> /root/.bashrc && echo "PATH=$PATH:$GOROOT/bin" >> /root/.bashrc

RUN echo "php version \c" && php -v && \
    echo "nginx version \c" && nginx -v && \
    echo "supervisor version \c" && /usr/bin/supervisord -v && \
    echo "nodejs version \c" && nodejs -v && \
    echo "npm version \c" && npm -v && \
    echo "cnpm version \c" && cnpm -v && \
    echo "yarn version \c" && yarn -v && \
    echo "composer version \c" && composer --version && \
    echo "php modules \c" && php -m && \
    echo "caddy version" && caddy -version
ENV TZ=Asia/Shanghai

Based on the basic image, we installed some common tools. Package it into an image again and upload it to dockerhub.
Docker image name issiya/ubuntu16.04-tool

4、 Use

Docker run Siya / Ubuntu 16.04-tool or docker pull Siya / Ubuntu 16.04-tool

Pull the image locally to use the modified image. Mount directory external mapping port, according to your own requirements.

Dockerhub address

siya/ubuntu16.04-tool dockerhub
siya/ubuntu16.04-vim-sshl dockerhub

Dockerfile address

siya/ubuntu16.04-tool dockerfile
siya/ubuntu16.04-vim-sshl dockerfile

This work adoptsCC agreement, reprint must indicate the author and the link to this article

siya

Recommended Today

Heavyweight Tencent cloud open source industry’s first etcd one-stop governance platform kstone

​ Kstone open source At the kubecon China Conference held by CNCF cloud native foundation on December 9, 2021,Tencent cloud container tke team released the open source project of kstone etcd governance platform. KstoneIt was initiated by the TKE team of Tencent cloud containerCloud native one-stop etcd governance project based on kubernetes。 The project originates […]