Warning
This guide has moved!
It is now maintained in the official Wasp docs: 👉 https://wasp.sh/docs/guides/deployment/caprover
This gist is archived and will no longer be updated.
Warning
This guide has moved!
It is now maintained in the official Wasp docs: 👉 https://wasp.sh/docs/guides/deployment/caprover
This gist is archived and will no longer be updated.
You'll need a Caprover server setup.
Then create three apps for your Wasp app:
serverclientSet the container ports:
server app -> 3001client app -> 8043Enable HTTPS and force redirects to HTTPS.
Adjust the captain-definition location in the Deployment tab:
server app -> captain-definition-serverclient app -> captain-definition-clientThe env variables you will need to set:
server app
DATABASE_URL (the DB you created on Caprover)
postgres://postgres:<pw>@srv-captain--<db-app-name>:5432/postgresWASP_WEB_CLIENT_URL the client url (custom domain or the Caprover assigned subdomain)JWT_SECRETclient app
SERVER_APP_URL the server urlAdding the following files to your Wasp app project:
captain-definition-clientcaptain-definition-servercaprover/Dockerfile.clientcaprover/Dockerfile.server.dockerignoreYou'll need a new private-public SSH key pair to add to the client and server apps (private key) and to the Github repo as the deploy key (public key) ... or just add the public key to your account.
You should add the Github webhook URls as push only to your Github repo (one for each client and server)
Set the SSL/TLS to Full (strict).
Change the A recrod to DNS only when you try to verify the domain (Clicking Enable HTTPS tries to verify the domain and it fails if the A record is proxied).
When you get a certificate for the domain, switch the A recrod back to proxied.
| { | |
| "schemaVersion": 2, | |
| "dockerfilePath": "./caprover/Dockerfile.client" | |
| } |
| { | |
| "schemaVersion": 2, | |
| "dockerfilePath": "./caprover/Dockerfile.server" | |
| } |
| # Building the Wasp app | |
| FROM --platform=linux/amd64 node:18 AS wasp-build | |
| ARG SERVER_APP_URL | |
| ENV SERVER_APP_URL=$SERVER_APP_URL | |
| RUN curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v 0.11.7 | |
| ENV PATH="/root/.local/bin:${PATH}" | |
| WORKDIR /app | |
| COPY . /app | |
| RUN wasp build | |
| # Building the client | |
| WORKDIR /app/.wasp/build/web-app | |
| RUN REACT_APP_API_URL=$SERVER_APP_URL npm run build | |
| # Serving the client | |
| FROM pierrezemb/gostatic | |
| CMD [ "-fallback", "index.html", "-enable-logging"] | |
| COPY --from=wasp-build /app/.wasp/build/web-app/build /srv/http |
| # Building the Wasp app | |
| FROM --platform=linux/amd64 node:18 AS wasp-build | |
| RUN curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v 0.11.7 | |
| ENV PATH="/root/.local/bin:${PATH}" | |
| WORKDIR /app | |
| COPY . /app | |
| RUN wasp build | |
| # Building the server | |
| FROM node:18-alpine3.17 AS node | |
| FROM node AS base | |
| RUN apk --no-cache -U upgrade # To ensure any potential security patches are applied. | |
| FROM base AS server-builder | |
| RUN apk add --no-cache build-base libtool autoconf automake | |
| WORKDIR /app | |
| COPY --from=wasp-build /app/.wasp/build/server/ ./server/ | |
| # Install npm packages, resulting in node_modules/. | |
| RUN cd server && npm install | |
| COPY --from=wasp-build /app/.wasp/build/db/schema.prisma ./db/ | |
| RUN cd server && PRISMA_CLIENT_OUTPUT_DIR=../server/node_modules/.prisma/client/ npx prisma generate --schema='../db/schema.prisma' | |
| # Building the server should come after Prisma generation. | |
| RUN cd server && npm run build | |
| # Serving the server | |
| FROM base AS server-production | |
| RUN apk add --no-cache python3 | |
| ENV NODE_ENV production | |
| WORKDIR /app | |
| COPY --from=server-builder /app/server/node_modules ./server/node_modules | |
| COPY --from=server-builder /app/server/dist ./server/dist | |
| COPY --from=server-builder /app/server/package*.json ./server/ | |
| COPY --from=server-builder /app/server/scripts ./server/scripts | |
| COPY --from=wasp-build /app/.wasp/build/db/ ./db/ | |
| EXPOSE ${PORT} | |
| WORKDIR /app/server | |
| ENTRYPOINT ["npm", "run", "start-production"] |
| .wasp/ | |
| .github/ | |
| .vscode/ | |
| caprover/ |