2022-01-10 12:50:42 +00:00
|
|
|
FROM crystallang/crystal:latest-alpine as deps
|
2022-01-08 12:29:22 +00:00
|
|
|
WORKDIR /app
|
|
|
|
RUN apk add curl --no-cache
|
|
|
|
COPY ./shard.yml ./shard.lock ./
|
2022-01-20 16:32:15 +00:00
|
|
|
RUN shards install --production
|
2022-01-08 12:29:22 +00:00
|
|
|
|
2022-01-10 12:50:42 +00:00
|
|
|
FROM crystallang/crystal:latest-alpine as builder
|
2022-01-08 12:29:22 +00:00
|
|
|
ARG BUILD_ENV
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=deps /app/shard.yml /app/shard.lock ./
|
|
|
|
COPY --from=deps /app/lib ./lib
|
|
|
|
COPY ./src ./src
|
2022-01-10 16:53:38 +00:00
|
|
|
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
|
2022-01-20 16:30:20 +00:00
|
|
|
|
|
|
|
FROM ubuntu:latest as user
|
2022-01-20 20:17:24 +00:00
|
|
|
RUN useradd -u 10001 api
|
2022-01-20 16:30:20 +00:00
|
|
|
|
2022-01-08 12:29:22 +00:00
|
|
|
FROM scratch as runner
|
2022-01-20 16:30:20 +00:00
|
|
|
WORKDIR /app
|
2022-01-20 16:58:15 +00:00
|
|
|
COPY --from=user /etc/passwd /etc/passwd
|
2022-01-20 20:17:24 +00:00
|
|
|
COPY --from=builder /app/bin/api /bin/api
|
2022-01-20 16:30:20 +00:00
|
|
|
COPY --from=builder /app/bin/micrate /bin/micrate
|
2022-01-10 12:50:42 +00:00
|
|
|
COPY ./db ./db
|
2022-01-20 20:17:24 +00:00
|
|
|
USER api
|
2022-01-15 19:04:31 +00:00
|
|
|
EXPOSE 80
|
2022-01-20 20:17:24 +00:00
|
|
|
ENTRYPOINT [ "api" ]
|