个人Dockerfile分享

发布于:2025-02-19 ⋅ 阅读:(21) ⋅ 点赞:(0)

nginx


[root@docker docker]# cat Dockerfile 
FROM nginx:1.20.1-alpine
COPY /dist  /usr/local/web/
COPY nginx.conf /etc/nginx/nginx.conf
CMD ["nginx", "-g", "daemon off;"]

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - r e m o t e u s e r [ remote_user [ remoteuser[time_local] “KaTeX parse error: Double superscript at position 32: … '̲status b o d y b y t e s s e n t " body_bytes_sent " bodybytessent"http_referer” ’
‘“ h t t p u s e r a g e n t " " http_user_agent" " httpuseragent""http_x_forwarded_for”’;
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
real_ip_header X-Real-IP;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

location / {
  root   /usr/local/web;
  index  index.html;
  try_files $uri $uri/ /index.html;
}
error_page   500 502 503 504  /50x.html;
location = /50x.html {
  root   /usr/share/nginx/html;
}

}
}

centos


FROM centos:centos7.9.2009

ENV LC_ALL=“en_US.utf8”

RUN yum install -y wget &&
rm -rf /etc/yum.repos.d/* &&
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo &&
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo &&
yum update -y &&
yum install -y telnet net-tools vim &&
yum clean all &&
rm -rf /tmp/* rm -rf /var/cache/yum/* &&
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&
echo “Asia/Shanghai” > /etc/timezone

CMD [“/bin/bash”]

java


FROM anapsix/alpine-java:8u202b08_jdk

RUN echo ‘http://mirrors.ustc.edu.cn/alpine/v3.5/main’ > /etc/apk/repositories
&& echo ‘http://mirrors.ustc.edu.cn/alpine/v3.5/community’ >>/etc/apk/repositories
&& apk update && apk add tzdata
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo “Asia/Shanghai” > /etc/timezones

CMD [“/bin/bash”]

rocksdb


FROM centos:centos7

USER root

ADD go1.17.linux-amd64.tar.gz /usr/local/
ADD cmake-3.6.0-Linux-x86_64.tar.gz /data
ADD gflags-2.2.2.tar.gz /data
ADD rocksdb-6.4.6.tar.gz /data
ADD zstd-1.1.3.tar.gz /data

RUN yum install -y gcc gcc-c++ lrzsz git lz4-devel snappy snappy-devel zlib zlib-devel bzip2 bzip2-devel lz4 lz4-devel &&
cd /data &&
yum remove cmake &&
echo “export PATH=$PATH:/data/cmake-3.6.0-Linux-x86_64/bin” >> /etc/profile &&
source /etc/profile &&
echo “export GOROOT=/usr/local/go” >> /etc/profile &&
echo “export PATH=$PATH:/usr/local/go/bin” >> /etc/profile &&
source /etc/profile &&
cd /data/gflags-2.2.2 && mkdir build && cd build &&
cmake -DBUILD_SHARED_LIBS=ON -DBUILD_STATICaaa_LIBS=ON -DINSTALL_HEADERS=ON -DINSTALL_SHARED_LIBS=ON -DINSTALL_STATIC_LIBS=ON … &&
make -j 5 && make install &&
echo “export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib” >> /etc/profile &&
cd /data/zstd-1.1.3 &&
make -j 5 && make install &&
cd /data/rocksdb-6.4.6 &&
make -j 5 static_lib &&
make -j 5 shared_lib &&
cp librocksdb.so.6.4.6 /usr/local/lib &&
ln -s librocksdb.so.6.4.6 /usr/local/lib/librocksdb.so.6.4 &&
ln -s librocksdb.so.6.4.6 /usr/local/lib/librocksdb.so.6 &&
ln -s librocksdb.so.6.4.6 /usr/local/lib/librocksdb.so &&
echo “export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib” >> /etc/profile &&
source /etc/profile

CMD tail -f /etc/hosts

#!/bin/bash
rocksdb_datadir=/data/rocksdbTemp

mkdir -p ${rocksdb_datadir}
cd /data
cat > rocksdbtest.cpp << EOF
#include
#include

#include “rocksdb/db.h”
#include “rocksdb/slice.h”
#include “rocksdb/options.h”

using namespace std;
using namespace rocksdb;

const std::string PATH = “${rocksdb_datadir}”; //rocksDB的数据存储目录绝对路径

int main(){
DB* db;
Options options;
options.create_if_missing = true;
Status status = DB::Open(options, PATH, &db);
assert(status.ok());
Slice key(“test01”);
Slice value(“success”);

std::string get_value;
status = db->Put(WriteOptions(), key, value);
if(status.ok()){
    status = db->Get(ReadOptions(), key, &get_value);
    if(status.ok()){
        printf("value is %s\n", get_value.c_str());
    }else{
        printf("get failed\n"); 
    }
}else{
    printf("put failed\n");
}

delete db;

}
EOF
g++ -std=c++11 -o rocksdbtest2 rocksdbtest.cpp -I /data/rocksdb-6.4.6/include -L/data/rocksdb-6.4.6 -lrocksdb -ldl
./rocksdbtest2


网站公告

今日签到

点亮在社区的每一天
去签到