Improve cacheability
All checks were successful
Build and Publish Docker Image / build_and_push (push) Successful in 42s
All checks were successful
Build and Publish Docker Image / build_and_push (push) Successful in 42s
This commit is contained in:
@@ -4,4 +4,5 @@ GIPHY_API_KEY=
|
|||||||
PLANTNET_API_KEY=
|
PLANTNET_API_KEY=
|
||||||
OMDB_API_KEY=
|
OMDB_API_KEY=
|
||||||
REPLICATE_API_KEY=
|
REPLICATE_API_KEY=
|
||||||
MONGODB_URI=
|
MONGODB_URI=
|
||||||
|
REGISTER_SLASH_COMMANDS=
|
||||||
38
Dockerfile
38
Dockerfile
@@ -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
|
# Create app directory and copy the app
|
||||||
WORKDIR /app
|
COPY package*.json tsconfig.json ./
|
||||||
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
|
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
|
# Copy the app
|
||||||
|
COPY src ./src
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
RUN npm run 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
|
# Start the app
|
||||||
ENTRYPOINT ["npm", "run"]
|
ENTRYPOINT ["npm", "run"]
|
||||||
CMD ["start"]
|
CMD ["start"]
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ interface Config {
|
|||||||
omdbApiKey: string;
|
omdbApiKey: string;
|
||||||
replicateApiKey: string;
|
replicateApiKey: string;
|
||||||
mongodbUri: string;
|
mongodbUri: string;
|
||||||
registerSlashCommands?: boolean;
|
registerSlashCommands: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getEnv = (key: string, required = true): string | boolean | undefined => {
|
const getEnv = (key: string, required = true): string | boolean | undefined => {
|
||||||
@@ -29,7 +29,8 @@ const config: Config = {
|
|||||||
omdbApiKey: getEnv('OMDB_API_KEY') as string,
|
omdbApiKey: getEnv('OMDB_API_KEY') as string,
|
||||||
replicateApiKey: getEnv('REPLICATE_API_KEY') as string,
|
replicateApiKey: getEnv('REPLICATE_API_KEY') as string,
|
||||||
mongodbUri: getEnv('MONGODB_URI') 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;
|
export default config;
|
||||||
|
|||||||
Reference in New Issue
Block a user