develop #2

Merged
jack merged 10 commits from develop into main 2024-09-16 14:50:32 +00:00
3 changed files with 32 additions and 14 deletions
Showing only changes of commit 83ce2f6f57 - Show all commits

View File

@@ -4,4 +4,5 @@ GIPHY_API_KEY=
PLANTNET_API_KEY=
OMDB_API_KEY=
REPLICATE_API_KEY=
MONGODB_URI=
MONGODB_URI=
REGISTER_SLASH_COMMANDS=

View File

@@ -1,22 +1,38 @@
FROM node:lts-alpine
################################################
FROM node:lts-alpine AS base
# Create user and group
RUN mkdir /app && \
addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
chown -R nodejs:nodejs /app
WORKDIR /app
################################################
FROM base AS build
# Create app directory and copy the app
WORKDIR /app
COPY . .
# Run as non-root user
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nodejs -u 1001
RUN chown -R nodejs:nodejs /app
USER nodejs
COPY package*.json tsconfig.json ./
# Install
RUN npm install
# Copy the app
COPY src ./src
# Build
RUN npm run build
################################################
FROM node:lts-alpine
COPY --from=build /app/package*.json ./
COPY --from=build /app/dist ./dist
# Install dependencies but skip dev dependencies
RUN npm install --only=production
# Start the app
ENTRYPOINT ["npm", "run"]
CMD ["start"]
CMD ["start"]

View File

@@ -10,7 +10,7 @@ interface Config {
omdbApiKey: string;
replicateApiKey: string;
mongodbUri: string;
registerSlashCommands?: boolean;
registerSlashCommands: boolean;
}
const getEnv = (key: string, required = true): string | boolean | undefined => {
@@ -29,7 +29,8 @@ const config: Config = {
omdbApiKey: getEnv('OMDB_API_KEY') as string,
replicateApiKey: getEnv('REPLICATE_API_KEY') as string,
mongodbUri: getEnv('MONGODB_URI') as string,
registerSlashCommands: getEnv('REGISTER_SLASH_COMMANDS', false) as boolean,
registerSlashCommands:
(getEnv('REGISTER_SLASH_COMMANDS', false) as boolean) || false, // Default to false
};
export default config;