strapi-community / strapi-tool-dockerize

Easy add support for docker to your strapi project
MIT License
543 stars 35 forks source link

Deployments via AWS Elasticbeanstalk Fail #24

Closed selected-pixel-jameson closed 2 years ago

selected-pixel-jameson commented 2 years ago

This isn't working for me when deploying using ElasticBeanstalk and CodePipeline on AWS.

This is what I have for my Dockerfile, which was generated via this library.

FROM node:16-alpine
RUN apk update && apk add  build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/
COPY ./package.json ./yarn.lock ./
ENV PATH /opt/node_modules/.bin:$PATH
RUN yarn config set network-timeout 600000 -g && yarn install
WORKDIR /opt/app
COPY ./ .
RUN yarn build
EXPOSE 1337
CMD ["yarn", "develop"]

The build fails and I can't even get the logs printed out. I'm using the latest Docker Image (Docker running on 64bit Amazon Linux 2/3.4.18) and deploying through CodePipeline. I'm not doing any builds on the server. If ElasticBeanstalk sees a Dockerfile it will build without any issues.

My previous Dockerfile worked fine until they updated the dependencies in Strapi to require NodeJS 14.19+.

FROM strapi/base

WORKDIR /4track-strapi

COPY ./package.json ./
COPY ./yarn.lock ./
COPY ./providers/ ./providers

RUN yarn install

COPY . .

ENV NODE_ENV production
ENV ENV_PATH .env

RUN yarn build

EXPOSE 1337

CMD ["yarn", "start"]

Any help would be very much appreciated.

Eventyret commented 2 years ago

Thanks for your question. one you are using is the strapi/base which is built for strapi 3. The plugin is using Strapi 4 btw as there is a difference in folder structure. Though the dockerfile should work

Does this fail during the pipeline build, does it build locally ? If it fails in the pipeline make sure your using the nodejs platform that is supported https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platform-history-nodejs.html

selected-pixel-jameson commented 2 years ago

Thank you for the reply.

We are not using a NodeJS Image and the pipeline is not executing a build step. The build fails when it’s being deployed on Elasticbeanstalk. Elasticbeanstalk will recognize the Dockerfile and run it during deployment so it’s failing when the Dockerfile is run. Unfortunately I can’t even get the logs to generate so I’m unable to share those.

The strapi/base image worked for this up until the NodeJS version required changed to 14.9+.

Jameson W Parker

On Aug 17, 2022, at 3:53 AM, Simen Daehlin @.***> wrote:

 Thanks for your question. one you are using is the strapi/base which is built for strapi 3. The plugin is using Strapi 4 btw as there is a difference in folder structure. Though the dockerfile should work

Does this fail during the pipeline build, does it build locally ? If it fails in the pipeline make sure your using the nodejs platform that is supported https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platform-history-nodejs.html

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

selected-pixel-jameson commented 2 years ago

Eventually I got this to work.

This is what I ended up with in my Dockerfile.

FROM node:16-alpine

WORKDIR [root_directory_name]

RUN apk update && apk add  build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev

COPY ./package.json ./
COPY ./yarn.lock ./

RUN yarn install

COPY . .

ENV NODE_ENV production
ENV ENV_PATH .env

RUN yarn build
EXPOSE 1337
CMD ["yarn", "start"]
Eventyret commented 2 years ago

Oh i see what you changed. Glad you got this worked, I will close this ticket.

But it seems that it was the workdir then.