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 \
|
2022-01-29 15:40:39 +00:00
|
|
|
time shards build -Ddevelopment --static --verbose -s -p -t; \
|
2022-01-10 16:53:38 +00:00
|
|
|
else \
|
2022-01-28 17:30:20 +00:00
|
|
|
time shards build --static --release --no-debug --verbose -s -p -t; \
|
2022-01-10 16:53:38 +00:00
|
|
|
fi
|
2022-01-20 16:30:20 +00:00
|
|
|
|
2022-01-28 17:30:20 +00:00
|
|
|
FROM alpine as runner
|
2022-01-20 16:30:20 +00:00
|
|
|
WORKDIR /app
|
2022-01-29 15:40:39 +00:00
|
|
|
RUN adduser -S backend -u 1001
|
2022-01-28 17:30:20 +00:00
|
|
|
COPY --from=builder /app/bin ./bin
|
2022-01-10 12:50:42 +00:00
|
|
|
COPY ./db ./db
|
2022-01-23 08:12:57 +00:00
|
|
|
USER backend
|
2022-01-15 19:04:31 +00:00
|
|
|
EXPOSE 80
|
2022-01-28 17:30:20 +00:00
|
|
|
ENTRYPOINT [ "./bin/backend" ]
|
2022-01-23 08:12:57 +00:00
|
|
|
CMD [ "run" ]
|