diff --git a/Containerfile b/Containerfile index c8cb092..991cd51 100644 --- a/Containerfile +++ b/Containerfile @@ -8,8 +8,10 @@ COPY . . RUN npm run build FROM node:21-alpine -USER node:node WORKDIR /app +RUN chown -R node:node /app +USER node:node +COPY ./container/entrypoint.sh /entrypoint.sh COPY package.json . COPY --from=builder /app/build ./build -CMD ["node", "./build/index.js"] +ENTRYPOINT ["sh", "/entrypoint.sh"] diff --git a/container/entrypoint.sh b/container/entrypoint.sh new file mode 100755 index 0000000..9675a14 --- /dev/null +++ b/container/entrypoint.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env sh + +set -e + +export STORAGE_PATH="${STORAGE_PATH:-./uploads}" + +entrypoint() { + mkdir -p "${STORAGE_PATH}" + node ./build/index.js +} + +entrypoint diff --git a/src/lib/index.ts b/src/lib/index.ts index c609a73..b3d4e55 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1,6 +1,6 @@ // place files you want to import through the `$lib` alias in this folder. const safePath = (input: string) => input.replace(/\W/g, ''); -export const storagePath: string = './uploads'; +export const storagePath: string = process.env.STORAGE_PATH; export default safePath;