Skip to content
This repository has been archived by the owner on Oct 9, 2022. It is now read-only.

Commit

Permalink
Refactor dockerfiles. (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
wi1dcard authored Jul 23, 2021
1 parent de1afcf commit 56ef153
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 120 deletions.
74 changes: 49 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,49 @@
FROM ubuntu:latest as builder
ARG DEBIAN_FRONTEND=noninteractive

COPY . shadow
RUN apt-get update && apt-get -y upgrade \
&& apt-get -y install golang cargo libssl-dev clang-tools \
&& cd shadow \
&& cargo build --release -vv \
&& mkdir /target \
&& cp /shadow/target/release/shadow /target \
&& cp /usr/local/lib/libdarwinia_shadow.so /target \
&& cp /lib/x86_64-linux-gnu/libssl.so.1.1 /target \
&& cp /lib/x86_64-linux-gnu/libcrypto.so.1.1 /target

FROM ubuntu:latest
COPY --from=builder /target /target
RUN apt-get update -y \
&& apt-get install -y ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& mv /target/shadow /usr/bin \
&& mv /target/* /usr/lib \
&& rm -rf /target \
&& ldconfig

ENTRYPOINT ["shadow"]
FROM rust:1 as builder

ENV CARGO_TERM_COLOR=always
ENV LIBRARY_TYPE=static

RUN apt-get update
RUN apt-get install -y clang

##
# Update Rust toolchains
##

ARG RUST_TOOLCHAIN=nightly-2021-02-28
RUN rustup update \
&& rustup install ${RUST_TOOLCHAIN} \
&& rustup default ${RUST_TOOLCHAIN}

##
# Install Go
##

RUN wget https://golang.org/dl/go1.15.1.linux-amd64.tar.gz
RUN tar -C /usr/local -xvzf go*.linux-amd64.tar.gz

ENV PATH="$PATH:/usr/local/go/bin"
RUN go version

##
# Build
##

WORKDIR /src
COPY . .

RUN cargo build --release

##
# Final stage
##

FROM debian:stable-slim

RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /src/target/release/shadow /usr/local/bin/

ENTRYPOINT [ "/usr/local/bin/shadow" ]
29 changes: 0 additions & 29 deletions Dockerfiles/alpine.Dockerfile

This file was deleted.

33 changes: 0 additions & 33 deletions Dockerfiles/builder.Dockerfile

This file was deleted.

33 changes: 0 additions & 33 deletions Dockerfiles/release.Dockerfile

This file was deleted.

0 comments on commit 56ef153

Please sign in to comment.