[#44] [#44] Release container now builds & packages frontend as well

pull/53/head
Jef Roosens 2021-04-29 10:45:42 +02:00
parent 628a918682
commit e0ac8ddd24
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
2 changed files with 41 additions and 8 deletions

View File

@ -1,20 +1,42 @@
* *
# Source code # =====BACKEND=====
## Source code
!src/ !src/
# Cargo files ## Cargo files
!Cargo.toml !Cargo.toml
!Cargo.lock !Cargo.lock
# Entrypoint for devop container ## Entrypoint for devop container
!docker/entrypoint_dev.sh !docker/entrypoint_dev.sh
!docker/entrypoint.sh !docker/entrypoint.sh
# Config file ## Config file
!Rocket.toml !Rocket.toml
# Database migrations ## Database migrations
!migrations/ !migrations/
## Crontab for release container
!docker/crontab !docker/crontab
# =====FRONTEND=====
## Source code
!web/src/
## Public assets
!web/public/
!web/index.html
## Production env file
!web/.env.production
## Package manager stuff
!web/package.json
!web/yarn.lock
## Project configs
!web/tsconfig.json
!web/vite.config.ts

View File

@ -1,5 +1,5 @@
# vim: filetype=dockerfile # vim: filetype=dockerfile
FROM chewingbever/fej-builder:latest AS builder FROM chewingbever/fej-builder:latest AS backend-builder
COPY --chown=builder:builder Cargo.toml Cargo.lock ./ COPY --chown=builder:builder Cargo.toml Cargo.lock ./
COPY --chown=builder:builder src/ ./src/ COPY --chown=builder:builder src/ ./src/
@ -22,6 +22,16 @@ RUN cargo install \
--target x86_64-unknown-linux-musl --target x86_64-unknown-linux-musl
FROM node:15-alpine3.13 AS frontend-builder
COPY ./web /app
WORKDIR /app
# Build the frontend
RUN yarn install && \
yarn run build
# Now, we create the actual image # Now, we create the actual image
FROM alpine:3.13.5 FROM alpine:3.13.5
COPY ./docker/crontab /var/spool/cron/crontabs/fej COPY ./docker/crontab /var/spool/cron/crontabs/fej
@ -41,8 +51,9 @@ RUN apk update && \
# Switch to non-root user # Switch to non-root user
USER fej:fej USER fej:fej
# Copy binary over to final image # Copy binary & frontend over to final image
COPY --from=builder --chown=fej:fej /app/output/bin /app/bin COPY --from=backend-builder --chown=fej:fej /app/output/bin /app/bin
COPY --from=frontend-builder --chown=fej:fej /app/dist /app/dist
# Embed config file inside container # Embed config file inside container
# The workdir is changed so that the config file is read properly # The workdir is changed so that the config file is read properly