Git Product home page Git Product logo

Comments (25)

kwiat1990 avatar kwiat1990 commented on June 6, 2024 24

I was a bit confused when I followed the Docker installation on documentation page for Strapi v4 and got v3.6.8 in the end. Docs should point out that it's not yet an v4 image, otherwise people waste their time 😉.

from strapi-docker.

mklueh avatar mklueh commented on June 6, 2024 13

Wouldn't it be better to just have a Github Action in the main repo that creates and publishes a new Docker image for every version that gets released?

An extra repo looks like manual maintenance overhead at the cost of outdated Docker images

from strapi-docker.

ziudeso avatar ziudeso commented on June 6, 2024 12

Here's my 2 cents

Docker-compose.yml

version: "3"

services:
  strapi:
    # image: strapi/strapi
    build: 
      context: .
      args:
        BASE_VERSION: latest
        STRAPI_VERSION: 4.0.0
    container_name: strapi
    restart: unless-stopped
    env_file: .env
    environment:
      DATABASE_PORT_PROD: ${DATABASE_PORT_PROD}
      DATABASE_USERNAME_PROD: ${DATABASE_USERNAME_PROD}
      DATABASE_PASSWORD_PROD: ${DATABASE_PASSWORD_PROD}
      DATABASE_HOST_PROD: ${DATABASE_HOST_PROD}
      DATABASE_NAME_PROD: ${DATABASE_NAME_PROD}
      NODE_ENV: ${NODE_ENV}
      HOST: ${HOST}
      PORT: ${PORT}
    volumes:
      - .:/srv/app
    ports:
      - "1337:1337"

Dockerfile

ARG BASE_VERSION
FROM strapi/base:${BASE_VERSION}

ARG STRAPI_VERSION
RUN yarn global add @strapi/strapi@${STRAPI_VERSION}

RUN mkdir /srv/app && chown 1000:1000 -R /srv/app

WORKDIR /srv/app

VOLUME /srv/app

COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod 777 /usr/local/bin/docker-entrypoint.sh 
ENTRYPOINT ["docker-entrypoint.sh"]

CMD ["strapi", "develop"]

and finally the docker-entrypoint.sh is exactly the same as in this repo.

It works on my ubuntu 18.04 machine

from strapi-docker.

LeBenLeBen avatar LeBenLeBen commented on June 6, 2024 11

Please use the 👍 reaction on the initial message to share your interest. Posting the same message over and over creates noise by notifying everyone following this thread for no added value.

from strapi-docker.

benjaminpreiss avatar benjaminpreiss commented on June 6, 2024 10

Same here

There is a workaround though to get it running relatively easy in the meanwhile.
Create a local copy of the Dockerfile and entrypoint script. Then adjust this line in the Dockerfile to reference a different package: RUN yarn global add @strapi/strapi@${STRAPI_VERSION}.

Here is the updated Dockerfile

from strapi-docker.

PaulCorbeau avatar PaulCorbeau commented on June 6, 2024 10

Is there any plan for that ? I would like to use this docker image with the version >4 of Strapi.
Thanks

from strapi-docker.

naskio avatar naskio commented on June 6, 2024 10

Hi
Any updates ?
Thanks

from strapi-docker.

Vitorspk avatar Vitorspk commented on June 6, 2024 6

Hi,

Any news on this?

from strapi-docker.

kevinlaw91 avatar kevinlaw91 commented on June 6, 2024 5

Nope. In the background it tries to install the needed version from the yarn repository, but the latest version of strapi in yarn is:

yarn info strapi
...
    '3.6.8': '2021-08-24T09:01:20.840Z'

They changed the npm package name from strapi to @strapi/strapi

from strapi-docker.

egahmad avatar egahmad commented on June 6, 2024 5

I have made an updated version here egahmad/strapi-docker:latest

https://hub.docker.com/repository/docker/egahmad/strapi-docker

It's working in my end, the update was by this fork https://github.com/egahmad/strapi-docker

from strapi-docker.

nefarioustim avatar nefarioustim commented on June 6, 2024 4

Hey all.

I'm using Strapi hosted on AWS Fargate in production at a startup I CTO for, so the lack of maintenance of this repo has been somewhat frustrating since I want to upgrade to Strapi 4. Buoyed by @benjaminpreiss's comment above, I decided to fork the repo and have a go at generating my own base images:

https://github.com/grafaio/strapi-docker

This may be useful to others. My changes are:

  • I've limited the base box build to Node 16 only. If you want more, update the constants file.
  • I duplicated the change @benjaminpreiss recommended to ensure the Strapi 4 npm package is installed as latest.
  • I'm building on an M1 Mac and had some issues during build with sharp requiring a higher version of libvips, so I ensured both the Debian and Alpine builds install a higher version in the base box.
  • I'm using Yarn 3 locally, so I updated to include a .yarnrc that forces use of node_modules. I also updated the .gitignore to include new stuff generated by yarn.

At this point, I was able to build both the Debian and Alpine base boxes locally, and the subsequent Strapi derivatives using the somewhat old school build script as referenced at the bottom of the README:

yarn install
./bin/build.js

From here I've been able to docker run a new project using MySQL. One note: I had an issue here when I initially attempted to create my project using SQLite. There's an issue with the Node SQLite driver which you'll need to update once the docker run command has created your files but fails on building the project.

Hopefully my changes help someone else who finds this issue. If the maintainers want me to open a PR, just let me know.

from strapi-docker.

brunoprietog avatar brunoprietog commented on June 6, 2024 3

Hi,

Any news on this?

Thanks

from strapi-docker.

marianhlavac avatar marianhlavac commented on June 6, 2024 2

Is anyone even maintaining this?

from strapi-docker.

HannesOberreiter avatar HannesOberreiter commented on June 6, 2024 2

If anyone else is currently struggling with the Docker build of V4. There is currently a strapi third lib problem, which caused in my case a heap error each time when trying to create the docker build, even though I tried to increase the memory to the moon. 🌕

strapi/strapi#12160

Solution add to your package.json and rebuild the node_modules

"resolutions": {
    "**/colors": "1.4.0"
  }

Cheers
Hannes

from strapi-docker.

badan-cloud avatar badan-cloud commented on June 6, 2024

Same issue here.

from strapi-docker.

magisters-cc avatar magisters-cc commented on June 6, 2024

Same here.

from strapi-docker.

degitgitagitya avatar degitgitagitya commented on June 6, 2024

Waiting for this to migrate

from strapi-docker.

oghea avatar oghea commented on June 6, 2024

same issue here

from strapi-docker.

av1la avatar av1la commented on June 6, 2024

same here

from strapi-docker.

Slazerslaze avatar Slazerslaze commented on June 6, 2024

Same here

from strapi-docker.

badan-cloud avatar badan-cloud commented on June 6, 2024

Same here

There is a workaround though to get it running relatively easy in the meanwhile. Create a local copy of the Dockerfile and entrypoint script. Then adjust this line in the Dockerfile to reference a different package: RUN yarn global add @strapi/strapi@${STRAPI_VERSION}.

Here is the updated Dockerfile

Nope. In the background it tries to install the needed version from the yarn repository, but the latest version of strapi in yarn is:

yarn info strapi
...
    '3.6.8': '2021-08-24T09:01:20.840Z'

from strapi-docker.

jenkin avatar jenkin commented on June 6, 2024

If you want to install the graphql plugin, you can encounter a compatibility error.

yarn run v1.22.5
$ strapi install graphql
Command failed with exit code 1: yarn add @strapi/[email protected]
error [email protected]: The engine "node" is incompatible with this module. Expected version "^12.22.0 || ^14.17.0 || >= 16.0.0". Got "14.16.0"
error Found incompatible module.

You must update the Dockerfile provided by @ziudeso (see comment) to use node 14.17.0 (and not 14.16.0) as base image.

ARG NODE_VERSION
FROM node:${NODE_VERSION} AS base
EXPOSE 1337

ARG BASE_VERSION
#FROM strapi/base:${BASE_VERSION}
FROM base

...

You can now add the NODE_VERSION in your docker compose file and build.

...
  build:
    context: .
    args:
      NODE_VERSION: 14.17.0
      BASE_VERSION: latest
      STRAPI_VERSION: 4.0.2
...

from strapi-docker.

jkupcho avatar jkupcho commented on June 6, 2024

For those who don't want to mess around with compose handling image building, and maybe having a locally tagged docker image for use. As others have noted, there is a single change needed to be made into the strapi Dockerfile, given the npm package is scoped.

strapi/Dockerfile

# ... stuff
ARG STRAPI_VERSION
# this needs to change to @strapi/strapi rather than just strapi
RUN yarn global add @strapi/strapi@${STRAPI_VERSION} 
# ... more stuff

Building / Tagging

$ cd base
$ docker build --build-arg NODE_VERSION=lts-bullseye . -t strapi/base:4.0.3
$ cd ../strapi
$ docker build --build-arg BASE_VERSION=4.0.3 --build-arg STRAPI_VERSION=4.0.3 . -t strapi/strapi:4.0.3

Running

Once built, the entrypoint allows the run command to pass parameters at the end, so just use strapi start and you'll get a new strapi instance going without the need of overriding a whole bunch of stuff.

$ docker run -p 1337:1337 strapi/strapi:4.0.3 strapi start

Obviously, this could still be used in a docker-compose.yml, but rather than using compose to build the image, you could just reference the tag just built.

from strapi-docker.

tpimh avatar tpimh commented on June 6, 2024

I have found f90mora/strapi-4.0.3 image to work perfectly well for me (just needed to update to 4.0.4). Hope the official release is coming soon!

from strapi-docker.

derrickmehaffy avatar derrickmehaffy commented on June 6, 2024

See the update edit in the original post.

Going to lock this for now as we are well aware everyone wants docker images but at this time it's a low priority on our side as we never recommend using our images for production usage.

from strapi-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.