My Dockerfile for hosting Wappler NodeJS on Caprover

Dockerfile:

FROM node:16-bullseye-slim

ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV

ARG PORT=3000
ENV PORT $PORT
EXPOSE $PORT

RUN apt update && apt install jq -y

ENV PATH /opt/node_app/node_modules/.bin:$PATH

WORKDIR /opt/node_app

COPY package.json .
RUN npm install --no-optional
COPY . .

RUN jq '.options.connection.host = "{{$_ENV.DB_HOST}}" | .options.connection.port = "{{$_ENV.DB_PORT}}" | .options.connection.user = "{{$_ENV.DB_USER}}" | .options.connection.password = "{{$_ENV.DB_PASS}}" | .options.connection.database = "{{$_ENV.DB_NAME}}"' app/modules/connections/db.json > jq_out.json \
    && cp jq_out.json app/modules/connections/db.json

RUN jq '.debug = false' app/config/config.json > jq_out.json \
    && cp jq_out.json app/config/config.json

RUN jq '.env = {}' app/config/config.json > jq_out.json \
    && cp jq_out.json app/config/config.json

CMD [ "nodemon", "./index.js" ]

captain-definition.yml:

{
 "schemaVersion" :2 ,
 "dockerfilePath": "./Dockerfile"
}

The Dockerfile will patch Wappler files to read the following environment variables for the database named “db” (on Wappler):

DB_HOST
DB_PORT
DB_NAME
DB_USER
DB_PASS

Not handling Redis yet. Tagging @sid as he might find this useful

Todo:

Community Page
Last updated: