欢迎光临
我们一直在努力

Dockerfile两个From例子

由于研究tls分流器+v2ray+trojan的docker版,老是不能识别trojan流量

发现在dockerhub的tls-shunt-proxy只有一个但是版本太低了,还好这个大神有贴出他的Dockerfile

# Dockerfile for tls-shunt-proxy based alpine
# Copyright (C) 2019 - 2020 namowens
# Reference URL:
# https://github.com/liberal-boy/tls-shunt-proxy

# STEP 1 build executable binary

FROM golang:alpine AS builder #builder是别名
RUN apk update && apk add --no-cache git
WORKDIR /go/src/tls-shunt-proxy
RUN git clone --progress https://github.com/liberal-boy/tls-shunt-proxy.git . && \
    env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -tags "full" -ldflags "-s -w" -o /tmp/tsp && \
    chmod +x /tmp/tsp

# STEP 2 build a small image

FROM alpine
LABEL maintainer="namowens <[email protected]>"
LABEL version="0.5.3"
#从上一个from里复制
COPY --from=builder /tmp/tsp /usr/bin/tls-shunt-proxy/tls-shunt-proxy
COPY config.yaml /etc/tls-shunt-proxy/config.yaml
#把执行文件添加到Path里
ENV PATH /usr/bin/tls-shunt-proxy:$PATH
WORKDIR /etc/ssl/tls-shunt-proxy
CMD ["tls-shunt-proxy", "-config", "/etc/tls-shunt-proxy/config.yaml"]

修改下就可以变成自己的

# Dockerfile for tls-shunt-proxy based alpine
# Copyright (C) 2019 - 2020 namowens
# Reference URL:
# https://github.com/liberal-boy/tls-shunt-proxy

# STEP 1 build executable binary

FROM golang:alpine AS builder
RUN apk update && apk add --no-cache git
WORKDIR /go/src/tls-shunt-proxy
RUN git clone --progress https://github.com/liberal-boy/tls-shunt-proxy.git . && \
    env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -tags "full" -ldflags "-s -w" -o /tmp/tsp && \
    chmod +x /tmp/tsp

# STEP 2 build a small image

FROM alpine
LABEL maintainer="hqhyco <[email protected]>"
LABEL version="0.6.0"

COPY --from=builder /tmp/tsp /usr/bin/tls-shunt-proxy/tls-shunt-proxy
COPY config.yaml /etc/tls-shunt-proxy/config.yaml

ENV PATH /usr/bin/tls-shunt-proxy:$PATH
WORKDIR /etc/ssl/tls-shunt-proxy
CMD ["tls-shunt-proxy", "-config", "/etc/tls-shunt-proxy/config.yaml"]

可以看到第一个From是编译用的,安装了git

git下了tls-shunt-proxy的源码,然后GO编译

以后也可以用这个模板来制作其他在github上看到的源码

 收藏 (0) 打赏

您可以选择一种方式赞助本站

支付宝扫一扫赞助

微信钱包扫描赞助

未经允许不得转载:家里蹲的狐狸 » Dockerfile两个From例子

分享到: 生成海报
avatar

热门文章

  • 评论 抢沙发

    • QQ号
    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址

    登录

    忘记密码 ?

    切换登录

    注册

    我们将发送一封验证邮件至你的邮箱, 请正确填写以完成账号注册和激活