Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "2.4"
services:
strapi:
build: ./docker
ports:
- ${PORT:-1337}:1337
volumes:
- .:/srv/app/src/plugins/export-data
- ./plugins.js:/srv/app/config/plugins.js
volumes:
strapi:
31 changes: 31 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
ARG NODE_VERSION=18
FROM node:${NODE_VERSION}-alpine AS base-alpine
EXPOSE 1337

FROM base-alpine

ARG STRAPI_VERSION=latest

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


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

WORKDIR /srv/app

RUN strapi new ./ --no-run \
--dbclient=sqlite


RUN yarn install --prod --silent
RUN yarn add @faker-js/faker --dev
RUN mkdir src/plugins
# copy sources
COPY --link ../ ./src/plugins/export-data/
COPY --link api ./src/api
COPY --link index.js ./src/index.js
RUN rm -Rf ./src/plugins/export-data/docker/

#RUN "yarn"

CMD ["strapi","develop"]
Empty file added docker/api/.gitkeep
Empty file.
31 changes: 31 additions & 0 deletions docker/api/article/content-types/article/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"kind": "collectionType",
"collectionName": "articles",
"info": {
"singularName": "article",
"pluralName": "articles",
"displayName": "Article"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string"
},
"description": {
"type": "text"
},
"thumbnail": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
}
}
}
9 changes: 9 additions & 0 deletions docker/api/article/controllers/article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* article controller
*/

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::article.article');
9 changes: 9 additions & 0 deletions docker/api/article/routes/article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* article router
*/

const { createCoreRouter } = require('@strapi/strapi').factories;

module.exports = createCoreRouter('api::article.article');
9 changes: 9 additions & 0 deletions docker/api/article/services/article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* article service
*/

const { createCoreService } = require('@strapi/strapi').factories;

module.exports = createCoreService('api::article.article');
24 changes: 24 additions & 0 deletions docker/api/homepage/content-types/homepage/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"kind": "singleType",
"collectionName": "homepages",
"info": {
"singularName": "homepage",
"pluralName": "homepages",
"displayName": "Homepage"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string"
},
"cta_title": {
"type": "string"
},
"section_3_title": {
"type": "string"
}
}
}
9 changes: 9 additions & 0 deletions docker/api/homepage/controllers/homepage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* homepage controller
*/

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::homepage.homepage');
9 changes: 9 additions & 0 deletions docker/api/homepage/routes/homepage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* homepage router
*/

const { createCoreRouter } = require('@strapi/strapi').factories;

module.exports = createCoreRouter('api::homepage.homepage');
9 changes: 9 additions & 0 deletions docker/api/homepage/services/homepage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* homepage service
*/

const { createCoreService } = require('@strapi/strapi').factories;

module.exports = createCoreService('api::homepage.homepage');
41 changes: 41 additions & 0 deletions docker/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

module.exports = {
/**
* An asynchronous register function that runs before
* your application is initialized.
*
* This gives you an opportunity to extend code.
*/
register(/*{ strapi }*/) {},

/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*/
bootstrap({ strapi }) {
if(process.env.NODE_ENV === 'development'){
strapi.entityService.create('admin::user', {data: {
'firstname': 'John',
'lastname': 'Doe',
'email': 'test@example.com',
'password': 'test1234',
'isActive': true,
'created_at': new Date(),
'roles': [1]
},});
const {faker} = require('@faker-js/faker');
for(let i =0; i < 20000; i++) {
strapi.entityService.create('api::article.article',{
data:{
title: faker.lorem.sentence(),
description: faker.lorem.paragraphs(),
}
})
}
}
},
};
8 changes: 8 additions & 0 deletions plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
// ...
'export-data': {
enabled: true,
resolve: './src/plugins/export-data', // path to plugin folder
config: {}
},
}