aboutsummaryrefslogtreecommitdiffstats
path: root/extra/Dockerfile
blob: 3704acfac4c487171c1f0778c2190df538aab9e3 (plain)
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
34
35
36
37
38
39
40
41
42
# build image
FROM ekidd/rust-musl-builder:stable as builder

# pre-build dependencies in a fake workplace
RUN USER=root cargo new --bin es-public-proxy
WORKDIR ./es-public-proxy
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
RUN cargo build --release
RUN rm src/*.rs

# then mount in real source code (which may have been updated during dev) and build release binary
ADD . ./

RUN rm ./target/x86_64-unknown-linux-musl/release/deps/es_public_proxy*
RUN cargo build --release

# from here, the application environment
FROM alpine:latest

ARG APP=/usr/src/app

EXPOSE 9292

ENV TZ=Etc/UTC \
    APP_USER=appuser

RUN addgroup -S $APP_USER \
    && adduser -S -g $APP_USER $APP_USER

RUN apk update \
    && apk add --no-cache ca-certificates tzdata \
    && rm -rf /var/cache/apk/*

COPY --from=builder /home/rust/src/es-public-proxy/target/x86_64-unknown-linux-musl/release/es-public-proxy ${APP}/es-public-proxy

RUN chown -R $APP_USER:$APP_USER ${APP}

USER $APP_USER
WORKDIR ${APP}

CMD ["./es-public-proxy", "--unsafe-all-indices"]