常见的dockerfile汇总
python
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"]
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
php
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"]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
go
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 /app/backend /app/backend
COPY /build/zero/api/backend/etc /app/etc
EXPOSE 8888
CMD ["./backend"]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
node
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 /app/dist /usr/share/nginx/html
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
c++
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"]
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
jenkins
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 '27a\jenkins ALL=(ALL) NOPASSWD:ALL' /etc/sudoers \
&& apt install ansible -y
USER jenkins
ENV LANG C.UTF-8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
上次更新: 2023/03/02, 11:17:31