Skip to content

Instantly share code, notes, and snippets.

@infomiho
Last active September 22, 2023 09:54
Show Gist options
  • Save infomiho/69c168cd4577b84998cfc5095773bad5 to your computer and use it in GitHub Desktop.
Save infomiho/69c168cd4577b84998cfc5095773bad5 to your computer and use it in GitHub Desktop.
Red Hat UBI9 Wasp Deployment

Building Wasp for Red Hat's UBI9 image can be done with a custom Docker file and with a few simple steps that we encoded in the build.sh script.

Just put both the build.sh script and the Dockerfile at the root of your Wasp project. Make sure to make the build.sh executable with chmod +x build.sh.

There is also a test.sh script that builds the Docker image and runs it (to make sure it works)

set -e
server_url="http://localhost:8080"
# Build the app
wasp build
# Build the web-app
cd .wasp/build/web-app && REACT_APP_API_URL=$server_url npm run build && cd -
# Override the Dockerfile with the one in .wasp/build
cp Dockerfile .wasp/build
FROM --platform=linux/amd64 registry.access.redhat.com/ubi9/nodejs-18 AS builder
ARG SERVER_PORT=8080
ARG CLIENT_PORT=8081
ENV PORT=${SERVER_PORT}
ENV CLIENT_PORT=${CLIENT_PORT}
USER root
RUN npm install -g concurrently
RUN npm install -g serve
WORKDIR /app
COPY . .
RUN cd server && npm install
COPY db/schema.prisma ./db/
RUN cd server && PRISMA_CLIENT_OUTPUT_DIR=../server/node_modules/.prisma/client/ npx prisma generate --schema='../db/schema.prisma'
RUN cd server && npm run build
ENTRYPOINT concurrently "npm --prefix ./server run start-production" "serve ./web-app/build -l $CLIENT_PORT"
set -e
container_name="recipe-test"
server_port=8080
client_port=8081
client_url="http://localhost:8081"
database_url="postgresql://postgres@host.docker.internal:5432/testx"
# Build the container
cd .wasp/build && docker build . --build-arg="SERVER_PORT=$server_port" --build-arg="CLIENT_PORT=$client_port" -t $container_name && cd -
# Running the container to test, make sure to have a PostgreSQL instance running
docker run -p $server_port:$server_port -p $client_port:$client_port -e WASP_WEB_CLIENT_URL=$client_url -e DATABASE_URL=$database_url $container_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment