30 lines
781 B
Docker
30 lines
781 B
Docker
FROM crystallang/crystal:latest-alpine as deps
|
|
WORKDIR /app
|
|
RUN apk add curl --no-cache
|
|
COPY ./shard.yml ./shard.lock ./
|
|
RUN shards install --production
|
|
|
|
FROM crystallang/crystal:latest-alpine as builder
|
|
ARG BUILD_ENV
|
|
WORKDIR /app
|
|
COPY --from=deps /app/shard.yml /app/shard.lock ./
|
|
COPY --from=deps /app/lib ./lib
|
|
COPY ./src ./src
|
|
RUN if [ "${BUILD_ENV}" = "development" ]; then \
|
|
shards build --static --verbose -s -p -t; \
|
|
else \
|
|
shards build --static --release --no-debug --verbose -s -p -t; \
|
|
fi
|
|
|
|
FROM ubuntu:latest as user
|
|
RUN useradd -u 10001 mw
|
|
|
|
FROM scratch as runner
|
|
WORKDIR /app
|
|
COPY --from=builder /app/bin/mw /bin/mw
|
|
COPY --from=builder /app/bin/micrate /bin/micrate
|
|
COPY ./db ./db
|
|
COPY --from=user /etc/passwd /etc/passwd
|
|
USER mw
|
|
EXPOSE 80
|
|
ENTRYPOINT [ "mw" ]
|