Actix-web: docker build error

Created on 27 Sep 2019  路  3Comments  路  Source: actix/actix-web

error: cannot produce proc-macro for actix-web-codegen v0.1.2 as the target x86_64-unknown-linux-musl does not support these crate types

FROM rust:alpine

Most helpful comment

maybe you can build it in Debian and then running in alpine.

reference: https://github.com/alextanhongpin/rust-actix-docker/blob/master/Dockerfile

FROM rust:1.28.0-stretch as builder

# muslc is required in order to build the rust image.
RUN apt-get update && apt-get -y install ca-certificates cmake musl-tools libssl-dev && rm -rf /var/lib/apt/lists/*

COPY . .
RUN rustup target add x86_64-unknown-linux-musl
# Sets the environment variable for the cargo build command that follows.
ENV PKG_CONFIG_ALLOW_CROSS=1
RUN cargo build --target x86_64-unknown-linux-musl --release


FROM alpine:3.8

RUN apk --no-cache add ca-certificates 
COPY --from=builder /target/x86_64-unknown-linux-musl/release/rust-actix-web .

CMD ["/rust-actix-web"]

All 3 comments

nothing can be done from actix-web side

seems rust does not support proc-macro for musl target

maybe you can build it in Debian and then running in alpine.

reference: https://github.com/alextanhongpin/rust-actix-docker/blob/master/Dockerfile

FROM rust:1.28.0-stretch as builder

# muslc is required in order to build the rust image.
RUN apt-get update && apt-get -y install ca-certificates cmake musl-tools libssl-dev && rm -rf /var/lib/apt/lists/*

COPY . .
RUN rustup target add x86_64-unknown-linux-musl
# Sets the environment variable for the cargo build command that follows.
ENV PKG_CONFIG_ALLOW_CROSS=1
RUN cargo build --target x86_64-unknown-linux-musl --release


FROM alpine:3.8

RUN apk --no-cache add ca-certificates 
COPY --from=builder /target/x86_64-unknown-linux-musl/release/rust-actix-web .

CMD ["/rust-actix-web"]
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dadibom picture Dadibom  路  4Comments

uncotion picture uncotion  路  3Comments

zhaobingss picture zhaobingss  路  4Comments

joshsleeper picture joshsleeper  路  3Comments

Eilie picture Eilie  路  5Comments