试图通过修改镜像构建命令来优化镜像大小
版本
- FRP v0.36.2
优化
初始Dockerfile,基于golang,镜像大小:875MB
1 2 3 4 5 |
FROM golang ENV FRP_VERSION=0.36.2 RUN cd /root \ && wget -O - "https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_amd64.tar.gz" | tar -xzf - frp_${FRP_VERSION}_linux_amd64/frps frp_${FRP_VERSION}_linux_amd64/frps.ini --strip-components 1 ENTRYPOINT ["/root/frps", "-c", "/root/frps.ini"] |
改进Dockerfile,基于debian,镜像大小:157MB
1 2 3 4 5 6 7 |
FROM debian ENV FRP_VERSION=0.36.2 RUN apt update \ && apt install -y wget \ && cd /root \ && wget -O - "https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_amd64.tar.gz" | tar -xzf - frp_${FRP_VERSION}_linux_amd64/frps frp_${FRP_VERSION}_linux_amd64/frps.ini --strip-components 1 ENTRYPOINT ["/root/frps", "-c", "/root/frps.ini"] |
改进Dockerfile,基于debian:stable-slim,镜像大小:108MB
1 2 3 4 5 6 7 |
FROM debian:stable-slim ENV FRP_VERSION=0.36.2 RUN apt update \ && apt install -y wget \ && cd /root \ && wget -O - "https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_amd64.tar.gz" | tar -xzf - frp_${FRP_VERSION}_linux_amd64/frps frp_${FRP_VERSION}_linux_amd64/frps.ini --strip-components 1 ENTRYPOINT ["/root/frps", "-c", "/root/frps.ini"] |
改进Dockerfile,删除apt update list,镜像大小:90.8MB
1 2 3 4 5 6 7 8 |
FROM debian:stable-slim ENV FRP_VERSION=0.36.2 RUN apt update \ && apt install -y wget \ && rm -rf /var/lib/apt/lists/* \ && cd /root \ && wget -O - "https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_amd64.tar.gz" | tar -xzf - frp_${FRP_VERSION}_linux_amd64/frps frp_${FRP_VERSION}_linux_amd64/frps.ini --strip-components 1 ENTRYPOINT ["/root/frps", "-c", "/root/frps.ini"] |
改进Dockerfile,用ADD代替wget,镜像大小:91MB
1 2 3 4 5 6 |
FROM debian:stable-slim ENV FRP_VERSION=0.36.2 ADD https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_amd64.tar.gz /root/frp_${FRP_VERSION}_linux_amd64.tar.gz RUN cd /root \ tar -xzf frp_${FRP_VERSION}_linux_amd64.tar.gz frp_${FRP_VERSION}_linux_amd64/frps frp_${FRP_VERSION}_linux_amd64/frps.ini --strip-components 1 ENTRYPOINT ["/root/frps", "-c", "/root/frps.ini"] |
创建镜像
1 |
docker build -t minirplus/frps:test -f ./Dockerfile . |
创建容器
开发
1 |
docker run -it --rm --network host -v /root/frp/frps.ini:/root/frps.ini minirplus/frps |
生产
1 |
docker run --restart=always --network host -d -v /root/frp/frps.ini:/root/frps.ini --name frps minirplus/frps |
There are no comments yet