From 5ff66ce5ba2ccab07203fe7b7a3d55003a369c22 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sun, 20 Aug 2023 12:12:44 +0200 Subject: [PATCH] fix: Update Dockerfile --- Dockerfile | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index ffc541b..8e8b13a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,30 @@ -## Using Node 18.16.1 (LTS) on Alpine base +# Using Node 18.16.1 (LTS) on Alpine base FROM node:18.16-alpine -## Install npm build dependencies +# Install npm build dependencies and ffmpeg RUN apk add --no-cache python3 make build-base ffmpeg git -## Install Cadence -RUN git clone https://github.com/mariusbegby/cadence-discord-bot.git +# Clone Cadence repository - Shallow clone used to avoid including entire git history. +RUN git clone --depth 1 https://github.com/mariusbegby/cadence-discord-bot.git /cadence-discord-bot -## Run all subsequent commands from cadence root +# Set work directory for subsequent commands WORKDIR /cadence-discord-bot -# Copy .env and config.js to docker container +# Install dependencies from package-lock.json and omit dev dependencies +RUN npm ci --omit=dev + +# Remove unnecessary files +RUN rm -rf /assets +RUN rm -rf /.github + +# Copy .env and config file to docker container +# Do NOT share the built image with anyone as it will contain the .env file +# Optionally skip this step and set environment variables manually COPY .env .env COPY *local.js config/local.js -## Install node_modules -RUN npm install --production +# Deploy Slash Commands to Discord API RUN npm run deploy -## Cadence startup command +# Startup command to run the bot CMD [ "npm", "start" ]