Skip to content

Commit 6f15158

Browse files
authored
Use distroless base image and faster build approach (#281)
1 parent 6224a6b commit 6f15158

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

Dockerfile

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,18 @@
1313
# You should have received a copy of the GNU Affero General Public License
1414
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515

16-
# Compile
17-
FROM rust:1.67-alpine AS compiler
16+
FROM rust:1.67.0 as builder
1817

1918
WORKDIR /parseable
2019

21-
RUN apk add --no-cache musl-dev
22-
2320
COPY . .
2421

25-
RUN set -eux; \
26-
apkArch="$(apk --print-arch)"; \
27-
if [ "$apkArch" = "aarch64" ]; then \
28-
export JEMALLOC_SYS_WITH_LG_PAGE=16; \
29-
fi && \
30-
cargo build --release
31-
32-
# Run
33-
FROM alpine:3.16
34-
35-
RUN apk update --quiet \
36-
&& apk add -q --no-cache tini
37-
38-
# Create appuser
39-
ENV USER=parseable
40-
ENV UID=10001
41-
42-
RUN adduser \
43-
--disabled-password \
44-
--gecos "" \
45-
--home "/nonexistent" \
46-
--shell "/sbin/nologin" \
47-
--no-create-home \
48-
--uid "${UID}" \
49-
"${USER}"
22+
RUN cargo build --release
23+
24+
FROM gcr.io/distroless/cc:latest
5025

5126
WORKDIR /parseable
5227

53-
COPY --from=compiler /parseable/target/release/parseable /bin/parseable
54-
RUN chown -R parseable /parseable/
55-
56-
USER parseable:parseable
57-
58-
EXPOSE 8000/tcp
28+
COPY --from=builder /parseable/target/release/parseable /usr/local/bin/parseable
5929

60-
ENTRYPOINT ["tini", "--"]
61-
CMD /bin/parseable
30+
CMD ["/usr/local/bin/parseable"]

0 commit comments

Comments
 (0)