Skip to content

Commit

Permalink
Setup Caprover builds
Browse files Browse the repository at this point in the history
  • Loading branch information
infomiho committed Nov 11, 2023
1 parent 26b6a68 commit 23c2d03
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.wasp/
.github/
.vscode/
45 changes: 45 additions & 0 deletions caprover/Dockerfile.server
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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"]
4 changes: 4 additions & 0 deletions caprover/captain-definition-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"schemaVersion": 2,
"dockerfilePath": "./Dockerfile.server"
}
7 changes: 6 additions & 1 deletion env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ PEXELS_API_KEY=

OPENAI_API_KEY=

DATABASE_URL=
DATABASE_URL=

# Caprover variables
SERVER_APP=
CLIENT_APP=
CAPROVER_URL=
4 changes: 2 additions & 2 deletions main.wasp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ app socialpostgpt {
("@emotion/react", "11.10.6"),
("@emotion/styled", "11.10.6"),
("framer-motion", "6.5.1"),
("react-hook-form", "7.43.1"),
("react-hook-form", "^7.45.4"),
("@fontsource/inter", "4.5.15"),
("pexels", "1.4.0")
],
Expand Down Expand Up @@ -101,4 +101,4 @@ entity ImageAuthor {=psl
name String
url String
images Image[]
psl=}
psl=}

0 comments on commit 23c2d03

Please sign in to comment.