Update Rust version and use alpine for the image.

This commit is contained in:
Felipe Contreras 2022-10-22 16:24:05 -03:00
parent 91aff930d2
commit 08364a1b5a

View file

@ -1,8 +1,10 @@
##### Builder ####
FROM rust:1.62-slim-bullseye as builder
FROM rust:1.64-alpine as builder
RUN apt-get update && apt-get -y upgrade
RUN apt-get -y install --no-install-recommends sqlite3 libsqlite3-dev npm && rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache sqlite npm musl-dev
# Install Typescript
RUN npm install -g typescript
WORKDIR /usr/src
@ -18,9 +20,6 @@ WORKDIR /usr/src/huellas
# This is an empty build to get the dependencies cached.
RUN cargo build --release
# Install Typescript
RUN npm install -g typescript
# Now copy in the rest of the sources
COPY src /usr/src/huellas/src/
COPY migrations /usr/src/huellas/migrations/
@ -45,12 +44,15 @@ RUN npm install
# Transpile
RUN tsc
# Delete the first line of jvascript ts-client
RUN sed -i '1d' build/client.js
################
##### Runtime
FROM debian:bullseye-slim AS runtime
FROM alpine:3.16 AS Runtime
RUN apk add --no-cache sqlite
RUN apt-get update && apt-get -y upgrade
RUN apt-get -y install --no-install-recommends sqlite3 && rm -rf /var/lib/apt/lists/*
# Copy application binary from builder image
COPY --from=builder /usr/src/huellas/target/release/huellas /usr/local/bin
# Copy Rocket.toml
@ -60,8 +62,6 @@ COPY Rocket.toml /usr/local/bin
COPY static /usr/local/bin/static/
# Copy javascript client
COPY --from=builder /usr/src/huellas/ts-client/build/client.js /usr/local/bin/static
# Delete the first line of jvascript ts-client
RUN sed -i '1d' /usr/local/bin/static/client.js
# Run the application
WORKDIR /usr/local/bin