mentorenwahl/docker/backend/Dockerfile

45 lines
1.4 KiB
Docker

# Mentorenwahl: A fullstack application for assigning mentors to students based on their whishes.
# Copyright (C) 2022 Dominic Grimm
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM crystallang/crystal:1.3-alpine as deps
WORKDIR /app
COPY ./shard.yml ./shard.lock ./
RUN shards install --production
FROM crystallang/crystal:1.3-alpine as builder
ARG BUILD_ENV
WORKDIR /app/backend
COPY --from=deps /app/shard.yml /app/shard.lock ./
COPY --from=deps /app/lib ./lib
COPY ./LICENSE ./LICENSE
COPY ./Makefile ./Makefile
COPY ./src ./src
RUN if [ "${BUILD_ENV}" = "development" ]; then \
make dev; \
else \
make; \
fi
FROM alpine as runner
WORKDIR /app
RUN adduser -S backend -u 1001
COPY --from=builder /app/backend/bin ./bin
COPY ./db ./db
USER backend
EXPOSE 80
ENTRYPOINT [ "./bin/backend" ]
CMD [ "run" ]