Coder Social home page Coder Social logo

vw2c / docker-strapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from naskio/docker-strapi

0.0 0.0 0.0 68 KB

Docker image for strapi v4 (latest version)

Home Page: https://hub.docker.com/r/naskio/strapi

License: MIT License

Shell 71.31% Dockerfile 28.69%

docker-strapi's Introduction

strapi (v4+) containerized

Strapi

Docker image for strapi version 4 (latest version)

API creation made simple, secure and fast. The most advanced open-source Content Management Framework to build powerful API with no effort.

GitHub repository

Docker Hub

Docker Pulls


Example

Using Docker Compose, create docker-compose.yml file with the following content:

version: "3"
services:
  strapi:
    image: naskio/strapi
    environment:
      NODE_ENV: development # or production
    ports:
      - "1337:1337"
    # volumes:
    #   - ./app:/srv/app # mount an existing strapi project

or using Docker:

docker run -d -p 1337:1337 naskio/strapi --env NODE_ENV=development

You can find more example on GitHub.


How to use ?

This image allows you to create a new strapi project or run an existing strapi project.

  • for $NODE_ENV = development: The command that will run in your project is strapi develop.
  • for $NODE_ENV = production: The command that will run in your project is strapi start.

The Content-Type Builder plugin is disabled WHEN $NODE_ENV = production.

Creating a new strapi project

When running this image, strapi will check if there is a project in the /srv/app folder of the container. If there is nothing then it will run the strapi new command in the container /srv/app folder.

This command creates a project with an SQLite database. Then starts it on port 1337.

Environment variables

When creating a new project with this image you can pass database configurations to the strapi new command.

  • DATABASE_CLIENT a database provider supported by Strapi: (sqlite, postgres, mysql ,mongo).
  • DATABASE_HOST database host.
  • DATABASE_PORT database port.
  • DATABASE_NAME database name.
  • DATABASE_USERNAME database username.
  • DATABASE_PASSWORD database password.
  • DATABASE_SSL boolean for SSL.
  • EXTRA_ARGS pass extra args to the strapi new.

Running an existing strapi project

To run an existing project, you can mount the project folder in the container at /srv/app.


Recommended way to deploy an existing strapi project to production using Docker

To deploy an existing strapi project to production using Docker, it is recommended to build an image for your project based on node v18.

Example of Dockerfile:

FROM node:18
# alternatively you can use FROM strapi/base:latest
# Or use `FROM arm64v8/node:18` on arm64 architecture


# Set up working directory
WORKDIR /app

# Copy package.json to root directory
COPY package.json .

# Copy yarn.lock to root directory
COPY yarn.lock .

# Install dependencies, but not generate a yarn.lock file and fail if an update is needed
RUN yarn install --frozen-lockfile

# Copy strapi project files
COPY favicon.ico ./favicon.ico
COPY src/ src/
COPY public/ public/
COPY database/ database/
COPY config/ config/
# ...

# Build admin panel
RUN yarn build

# Run on port 1337
EXPOSE 1337

# Start strapi server
CMD ["yarn", "start"]

Official Documentation

  • The official documentation of strapi is available on https://docs.strapi.io/.

  • The official strapi docker image is available on GitHub (not yet upgraded to v4).

docker-strapi's People

Contributors

jongon avatar naskio avatar umcai avatar xc2f avatar

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.