This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Update Dockerfile and add .dockerignore
- Loading branch information
1 parent
ac40865
commit 054a07d
Showing
2 changed files
with
43 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Include any files or directories that you don't want to be copied to your | ||
# container here (e.g., local build artifacts, temporary files, etc.). | ||
# | ||
# For more help, visit the .dockerignore file reference guide at | ||
# https://docs.docker.com/engine/reference/builder/#dockerignore-file | ||
|
||
**/.dockerignore | ||
**/.env.example | ||
**/.git | ||
**/.gitignore | ||
**/.gitattributes | ||
**/.github | ||
**/.vscode | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/build | ||
**/dist | ||
**/logs | ||
**/assets | ||
.editorconfig | ||
.eslintrc.json | ||
.prettierrc | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
LICENSE.md | ||
PRIVACY-POLICY.md | ||
README.md | ||
SECURITY.md | ||
TERMS-OF-SERVICE.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,25 @@ | ||
# Using Node 18.16.1 (LTS) on Alpine base | ||
FROM node:18.16-alpine | ||
# syntax=docker/dockerfile:1 | ||
|
||
# Using Node 18.16 (LTS) on Alpine base | ||
ARG NODE_VERSION=18.16 | ||
FROM node:${NODE_VERSION}-alpine | ||
|
||
# Install npm build dependencies and ffmpeg | ||
RUN apk add --no-cache python3 make build-base ffmpeg 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 | ||
|
||
# Set work directory for subsequent commands | ||
WORKDIR /cadence-discord-bot | ||
|
||
# Install dependencies from package-lock.json and omit dev dependencies | ||
RUN npm ci --omit=dev | ||
# Copy the rest of the source files into the image. | ||
COPY . . | ||
|
||
# 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 dependencies from package-lock.json and omit dev dependencies | ||
# Leverage a cache mount to /root/.npm to speed up subsequent builds. | ||
RUN --mount=type=cache,target=/root/.npm \ | ||
npm ci --omit=dev | ||
|
||
# Deploy Slash Commands to Discord API | ||
RUN npm run deploy | ||
|
||
# Startup command to run the bot | ||
CMD [ "npm", "start" ] | ||
CMD [ "npm", "run", "start" ] |