Skip to content

Commit 174b0d3

Browse files
committed
fix dockerfile, static build on alpine
1 parent 2517ab7 commit 174b0d3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/target
22
site.db
33
docs/
4-
README.md
4+
README.md
5+
Dockerfile
6+
.dockerignore
7+
.github/

Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
FROM rust:1.63-slim-buster as builder
1+
FROM rust:1.63-alpine3.16 as builder
22
RUN rustup component add clippy rustfmt
3+
RUN apk add --no-cache musl-dev
34
WORKDIR /usr/src/sqlpage
45
RUN cargo init .
56
COPY Cargo.toml Cargo.lock .
67
RUN cargo build --release
78
COPY . .
8-
RUN cargo check --release && \
9+
RUN touch src/main.rs && \
910
cargo clippy --release && \
1011
cargo fmt --all -- --check && \
11-
cargo install --path .
12+
cargo test --release && \
13+
cargo build --release
1214

13-
FROM debian:buster-slim
14-
RUN apt-get update && apt-get upgrade --yes && apt-get install --yes openssl
15+
FROM alpine:3.16
1516
RUN rm -rf /var/lib/apt/lists/*
16-
COPY --from=builder /usr/local/cargo/bin/sqlpage /usr/local/bin/sqlpage
17-
RUN groupadd -r sqlpage && useradd --no-log-init -r -g sqlpage sqlpage
17+
COPY --from=builder /usr/src/sqlpage/target/release/sqlpage /usr/local/bin/sqlpage
18+
RUN addgroup -S sqlpage && adduser -S sqlpage -G sqlpage
1819
WORKDIR /var/www
1920
USER sqlpage
2021
EXPOSE 8080

0 commit comments

Comments
 (0)