常见的dockerfile汇总

2023-05-19 17:53:11 浏览数 (2)

python

代码语言:javascript复制
FROM python:3.7-alpine
WORKDIR /code
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
EXPOSE 5000
COPY . .
CMD ["flask", "run"]

php

代码语言:javascript复制
FROM php:7.2.34-fpm-alpine
WORKDIR /app
ENV TZ "Asia/Shanghai"
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g" /etc/apk/repositories 
&& apk add --no-cache autoconf g   libtool make curl-dev libxml2-dev linux-headers 
&& docker-php-ext-install -j 2 zip 
&& apk add --no-cache freetype-dev libjpeg-turbo-dev libpng-dev 
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 
&& docker-php-ext-install -j 2 gd 
&& docker-php-ext-install -j$(nproc) bcmath 
&& docker-php-ext-install -j 2 mysqli 
&& docker-php-ext-install pdo_mysql
copy . .
RUN chown -R www-data:www-data /app
EXPOSE 9000
ENTRYPOINT ["php-fpm"]

go

代码语言:javascript复制
FROM golang:1.16.7-alpine3.13 AS builder

LABEL stage=gobuilder

ENV CGO_ENABLED 0
ENV GOOS linux
ENV GOPROXY https://goproxy.cn,direct
ARG VERSION
ARG GIT_COMMIT
ARG GIT_TREE_STATE
ARG BUILD_DATE

WORKDIR /build/zero

ADD go.mod .
ADD go.sum .
RUN go mod download
COPY . .
RUN go build -ldflags="-s -w -X trade/common/version.GitVersion=${VERSION} -X trade/common/version.GitCommit=${GIT_COMMIT} -X trade/common/version.GitTreeState=${GIT_TREE_STATE} -X trade/common/version.BuildDate=${BUILD_DATE}" -o /app/backend api/backend/backend.go


FROM alpine:3.13
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN apk update --no-cache && apk add --no-cache ca-certificates tzdata
ENV TZ Asia/Shanghai

WORKDIR /app
COPY --from=builder /app/backend /app/backend
COPY --from=builder /build/zero/api/backend/etc /app/etc

EXPOSE 8888

CMD ["./backend"]

node

代码语言:javascript复制
FROM dh.1quant.me/library/node:8.15.0-alpine-i18n AS builder

LABEL stage=h5builder

WORKDIR /app

COPY . .

RUN npm cache verify && npm i && npm run build

FROM dh.1quant.me/library/nginx:1.14.2-alpine

COPY --from=builder /app/dist /usr/share/nginx/html

c

代码语言:javascript复制
FROM debian:buster

ENV TZ Asia/Shanghai

WORKDIR /app
ENV LD_LIBRARY_PATH=/app/lib

COPY . .
RUN ln -s libssl.so.1.0.2k ./lib/libssl.so.10 && ln -s libcrypto.so.1.0.2k ./lib/libcrypto.so.10

EXPOSE 9101

CMD ["./bin/trade_service"]

jenkins

代码语言:javascript复制
FROM jenkins/jenkins:2.332.3

USER root
RUN echo '' > /etc/apt/sources.list 
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free" > /etc/apt/sources.list 
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free" >> /etc/apt/sources.list 
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free" >> /etc/apt/sources.list 
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list 
&& apt update 
&& apt install sudo -y 
&& apt install vim -y 
&& apt install sshpass -y 
&& apt install python -y 
&& sed -i '27ajenkins ALL=(ALL)       NOPASSWD:ALL' /etc/sudoers 
&& apt install ansible -y
USER jenkins
ENV LANG C.UTF-8

0 人点赞