-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: web client bundled with service docker image (#134)
- web client is now bundled with the service docker image - the web client image is now deprecated, and only prints a warning - the web client no longer needs (nor renders) the 'connect to server' modal
- Loading branch information
1 parent
9e42bef
commit cf0faad
Showing
13 changed files
with
150 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,67 @@ | ||
FROM rust:slim-bookworm as builder | ||
FROM node:20-bookworm-slim AS common | ||
|
||
COPY . ./app | ||
|
||
### WEB CLIENT | ||
FROM node:20-bookworm-slim AS base | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
FROM base AS web-builder | ||
RUN apt-get update && apt-get install protobuf-compiler ca-certificates -y | ||
|
||
COPY --from=common /app /app | ||
WORKDIR /app | ||
|
||
RUN pnpm install --frozen-lockfile | ||
RUN pnpm exec buf generate | ||
RUN pnpm --filter=web build | ||
RUN pnpm deploy --filter=web /web | ||
RUN mv /app/packages/client/web/dist /web/dist | ||
|
||
### SERVICE BINARY | ||
FROM rust:slim-bookworm AS service-builder | ||
|
||
COPY --from=common /app /usr/src/retrom | ||
WORKDIR /usr/src/retrom | ||
COPY . . | ||
|
||
RUN apt-get update && apt-get install protobuf-compiler openssl pkg-config libssl-dev libpq-dev -y | ||
RUN cargo install --path ./packages/service | ||
|
||
FROM debian:bookworm-slim | ||
RUN apt-get update && apt-get install openssl libssl-dev libpq-dev ca-certificates -y && rm -rf /var/lib/apt/lists/* | ||
FROM base AS runner | ||
ENV UID=1505 | ||
ENV GID=1505 | ||
ENV UMASK=000 | ||
ENV USER=retrom | ||
|
||
ENV UID=1001 | ||
ENV GID=1001 | ||
RUN addgroup --gid $GID ${USER} | ||
RUN adduser --gid $GID --uid $UID ${USER} | ||
|
||
RUN apt-get update && apt-get install openssl libssl-dev libpq-dev ca-certificates -y | ||
|
||
### Service env | ||
ENV RUST_LOG=info | ||
ENV RETROM_CONFIG=/config/config.json | ||
EXPOSE 5101 | ||
|
||
### Web env | ||
ENV NODE_ENV=production | ||
ENV RETROM_LOCAL_SERVICE_HOST=http://localhost:5101 | ||
EXPOSE 3000 | ||
|
||
RUN addgroup --system --gid $GID retrom | ||
RUN adduser --system --uid $UID retrom | ||
COPY --from=service-builder /usr/local/cargo/bin/retrom-service /app/retrom-service | ||
COPY docker/start.sh /app/start.sh | ||
RUN chmod +x /app/start.sh | ||
|
||
COPY --from=builder /usr/local/cargo/bin/retrom-service /app/retrom-service | ||
COPY --from=web-builder /web /app/web | ||
|
||
RUN chmod -R 777 /app/web | ||
|
||
WORKDIR /app | ||
USER retrom | ||
|
||
ENV RETROM_CONFIG=/config/config.json | ||
USER ${USER} | ||
|
||
RUN umask ${UMASK} | ||
|
||
CMD ["./retrom-service"] | ||
CMD ./start.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Start the web server | ||
cd /app/web | ||
pnpm preview & | ||
|
||
# Start the API server | ||
cd /app | ||
|
||
./retrom-service & | ||
|
||
wait -n | ||
|
||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,4 @@ | ||
FROM node:20-alpine AS base | ||
FROM alpine:3.14 | ||
|
||
FROM base AS deps | ||
RUN apk add --no-cache libc6-compat protobuf-dev | ||
WORKDIR /app | ||
CMD echo 'This image has been deprecated. Please use the web-client bundled in retrom-service.' && exit 1 | ||
|
||
# top level deps | ||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ | ||
|
||
# package deps | ||
RUN mkdir -p packages/client/ && mkdir -p packages/codegen/ | ||
COPY buf*.yaml ./ | ||
COPY packages/codegen/protos/ ./packages/codegen/protos/ | ||
COPY packages/client/package.json ./packages/client/ | ||
COPY packages/client/web/ ./packages/client/web/ | ||
|
||
RUN corepack enable pnpm && pnpm i | ||
|
||
RUN pnpm exec buf generate | ||
|
||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/. ./ | ||
|
||
RUN corepack enable pnpm && pnpm --filter web build | ||
|
||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
ENV UID=1001 | ||
ENV GID=1001 | ||
ENV PORT=3000 | ||
ENV RETROM_PORT=5101 | ||
ENV RETROM_HOSTNAME=http://localhost | ||
ENV RETROM_HOST=http://localhost:5101 | ||
|
||
RUN addgroup --system --gid $GID retrom | ||
RUN adduser --system --uid $UID retrom | ||
|
||
|
||
COPY --from=builder --chown=retrom:retrom /app/packages/client/web/dist ./dist | ||
|
||
USER retrom | ||
|
||
EXPOSE $PORT | ||
|
||
CMD npx vite preview --host --port $PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.