mentorenwahl/docker/api/Dockerfile

31 lines
786 B
Docker
Raw Normal View History

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
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
FROM ubuntu:latest as user
2022-01-20 20:17:24 +00:00
RUN useradd -u 10001 api
2022-01-08 12:29:22 +00:00
FROM scratch as runner
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
COPY --from=builder /app/bin/micrate /bin/micrate
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" ]