Ramrachai / indigenous-connect-backend

To connect indigenous people of Bangladesh. Technology used Next.js, express.js, typescript, monogdb, AWS
0 stars 2 forks source link

[Docker] create a Docker File #15

Open nabarunchakma opened 1 month ago

nabarunchakma commented 1 month ago

This is to create a Docker file for ExpressJS API. The following can be used as inspiration.

# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".
FROM public.ecr.aws/docker/library/node:20.9.0-slim as builder
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_SESSION_TOKEN
ARG AWS_REGION=ap-southeast-2

RUN apt-get update && \
    apt-get install -y python3-launchpadlib software-properties-common && \
    add-apt-repository -y ppa:deadsnakes/ppa && \
    apt-get update && \
    apt-get install -y python3 python3-pip

RUN python3 -V &&  pip3 --version && \
    pip3 install awscli --break-system-packages

WORKDIR /usr/app
COPY . .
RUN yarn codeartifact:login
RUN yarn install --frozen-lockfile && yarn build && yarn build:esbuild

FROM public.ecr.aws/lambda/nodejs:20 as runner
EXPOSE 3000
WORKDIR ${LAMBDA_TASK_ROOT}
COPY --from=builder /usr/app/dist/* ./
CMD ["index.handler"]

Some reference guide.

https://www.geeksforgeeks.org/how-to-dockerize-an-expressjs-app/

ChakmaSajib commented 1 month ago

@nabarunchakma da, do you suggest to use projen package for this project?

nabarunchakma commented 1 month ago

@ChakmaSajib Projen is complex. I think team is not ready to support projen yet.