Add Dockerfile and script for self hosting
This commit is contained in:
63
self-hosting/Dockerfile
Normal file
63
self-hosting/Dockerfile
Normal file
@ -0,0 +1,63 @@
|
||||
FROM node:14.18-alpine as builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
|
||||
RUN apk add g++ make python3
|
||||
|
||||
COPY package.json .
|
||||
COPY yarn.lock .
|
||||
COPY tsconfig.json .
|
||||
COPY .prettierrc .
|
||||
COPY .eslintrc .
|
||||
|
||||
COPY selfhost.sh /app/selfhost.sh
|
||||
COPY /packages/readabilityjs/package.json ./packages/readabilityjs/package.json
|
||||
COPY /packages/api/package.json ./packages/api/package.json
|
||||
COPY /packages/text-to-speech/package.json ./packages/text-to-speech/package.json
|
||||
COPY /packages/content-handler/package.json ./packages/content-handler/package.json
|
||||
COPY /packages/db/package.json ./packages/db/package.json
|
||||
|
||||
RUN yarn install --pure-lockfile
|
||||
|
||||
ADD /packages/readabilityjs ./packages/readabilityjs
|
||||
ADD /packages/api ./packages/api
|
||||
ADD /packages/text-to-speech ./packages/text-to-speech
|
||||
ADD /packages/content-handler ./packages/content-handler
|
||||
ADD /packages/db ./packages/db
|
||||
|
||||
RUN yarn workspace @omnivore/text-to-speech-handler build
|
||||
RUN yarn workspace @omnivore/content-handler build
|
||||
RUN yarn workspace @omnivore/api build
|
||||
|
||||
RUN rm -rf /app/packages/api/node_modules
|
||||
RUN rm -rf /app/node_modules
|
||||
RUN yarn install --pure-lockfile --production
|
||||
|
||||
FROM node:14.18-alpine as runner
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV production
|
||||
ENV NODE_OPTIONS=--max-old-space-size=4096
|
||||
ENV PORT=8080
|
||||
|
||||
COPY --from=builder /app/packages/api/dist /app/packages/api/dist
|
||||
COPY --from=builder /app/packages/readabilityjs/ /app/packages/readabilityjs/
|
||||
COPY --from=builder /app/packages/api/package.json /app/packages/api/package.json
|
||||
COPY --from=builder /app/packages/api/node_modules /app/packages/api/node_modules
|
||||
COPY --from=builder /app/node_modules /app/node_modules
|
||||
COPY --from=builder /app/package.json /app/package.json
|
||||
COPY --from=builder /app/packages/text-to-speech/ /app/packages/text-to-speech/
|
||||
COPY --from=builder /app/packages/content-handler/ /app/packages/content-handler/
|
||||
COPY --from=builder /app/packages/db/ /app/packages/db/
|
||||
COPY --from=builder /app/selfhost.sh /app/selfhost.sh
|
||||
|
||||
RUN apk add postgresql-client
|
||||
RUN chmod 0755 /app/selfhost.sh
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
# Using a custom script to customize imageproxy startup and to pass
|
||||
# signatureKey through env variable
|
||||
ENTRYPOINT ["/app/selfhost.sh"]
|
||||
16
self-hosting/selfhost.sh
Normal file
16
self-hosting/selfhost.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "creating omnivore database with $(which psql)"
|
||||
psql --host $PG_HOST -U $PG_USER -c "CREATE DATABASE omnivore;"
|
||||
|
||||
echo "creating app_user"
|
||||
psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "CREATE USER app_user WITH PASSWORD 'app_pass';"
|
||||
echo "created app_user"
|
||||
|
||||
echo "running migrations"
|
||||
yarn workspace @omnivore/db migrate
|
||||
|
||||
psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "GRANT omnivore_user TO app_user;"
|
||||
echo "granted omnivore_user to app_user"
|
||||
|
||||
yarn workspace @omnivore/api start
|
||||
Reference in New Issue
Block a user