This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from strapi/chore/beta
Rebuild the docker images for strapi with beta
- Loading branch information
Showing
27 changed files
with
1,772 additions
and
160 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
env: { | ||
commonjs: true, | ||
es6: true, | ||
node: true, | ||
}, | ||
extends: 'eslint:recommended', | ||
globals: { | ||
Atomics: 'readonly', | ||
SharedArrayBuffer: 'readonly', | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
}, | ||
rules: {}, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
app | ||
db | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
language: node_js | ||
node_js: | ||
- 12 | ||
|
||
sudo: required | ||
|
||
services: | ||
- docker | ||
|
||
script: | ||
- docker build -t strapi/strapi . | ||
- docker-compose up -d | ||
- sleep 60 | ||
- curl -f localhost:1337 | ||
- docker logs strapidocker_api_1 | ||
- ./bin/build.js --type=all |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ARG NODE_VERSION | ||
FROM node:${NODE_VERSION} | ||
|
||
EXPOSE 1337 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ARG NODE_VERSION | ||
FROM node:${NODE_VERSION} | ||
|
||
RUN apk update && apk upgrade && apk add build-base gcc autoconf automake zlib-dev libpng-dev nasm | ||
|
||
EXPOSE 1337 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
'use strict'; | ||
|
||
const { execDocker } = require('./utils'); | ||
const { | ||
NODE_VERSIONS, | ||
BASE_IMAGE_NAME, | ||
LATEST_NODE_VERSION, | ||
} = require('./contstants'); | ||
|
||
module.exports = { | ||
buildBaseImages, | ||
}; | ||
|
||
async function buildBaseImages({ shouldPush = false } = {}) { | ||
const createdTags = []; | ||
for (const nodeVersion of NODE_VERSIONS) { | ||
const tags = await buildBaseImage({ nodeVersion, shouldPush }); | ||
const alpineTags = await buildBaseImage({ | ||
nodeVersion, | ||
alpine: true, | ||
shouldPush, | ||
}); | ||
|
||
createdTags.push(...tags, ...alpineTags); | ||
} | ||
|
||
return createdTags.map(tag => `${BASE_IMAGE_NAME}:${tag}`); | ||
} | ||
|
||
async function buildBaseImage({ nodeVersion, alpine, shouldPush = false }) { | ||
let tmpImg = `${BASE_IMAGE_NAME}:tmp`; | ||
|
||
await execDocker([ | ||
'build', | ||
'--build-arg', | ||
`NODE_VERSION=${nodeVersion}${alpine ? '-alpine' : ''}`, | ||
'-t', | ||
tmpImg, | ||
`./base${alpine ? '/alpine' : ''}`, | ||
]); | ||
|
||
const tags = buildBaseTags({ nodeVersion, alpine }); | ||
|
||
for (const tag of tags) { | ||
await execDocker(['tag', tmpImg, `${BASE_IMAGE_NAME}:${tag}`]); | ||
|
||
if (shouldPush) { | ||
await execDocker(['push', `${BASE_IMAGE_NAME}:${tag}`]); | ||
} | ||
} | ||
|
||
await execDocker(['image', 'rm', tmpImg]); | ||
return tags; | ||
} | ||
|
||
function buildBaseTags({ nodeVersion, alpine = false }) { | ||
let tags = []; | ||
|
||
tags.push(`${nodeVersion}${alpine ? '-alpine' : ''}`); | ||
|
||
if (nodeVersion === LATEST_NODE_VERSION && !alpine) { | ||
tags.push('latest'); | ||
} | ||
|
||
return tags; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
const yargs = require('yargs'); | ||
|
||
const { buildBaseImages } = require('./base'); | ||
const { buildStrapiImages } = require('./strapi'); | ||
|
||
async function run() { | ||
const shouldPush = argv.push; | ||
const version = argv.strapiVersion; | ||
|
||
switch (argv.type) { | ||
case 'base': { | ||
const images = await buildBaseImages({ shouldPush }); | ||
logImages(images); | ||
|
||
break; | ||
} | ||
case 'strapi': { | ||
const images = await buildStrapiImages({ version, shouldPush }); | ||
logImages(images); | ||
|
||
break; | ||
} | ||
case 'all': | ||
default: { | ||
const baseImages = await buildBaseImages({ shouldPush }); | ||
const strapiImages = await buildStrapiImages({ version, shouldPush }); | ||
logImages([...baseImages, ...strapiImages]); | ||
|
||
break; | ||
} | ||
} | ||
} | ||
|
||
const argv = yargs | ||
.option('type', { | ||
alias: 't', | ||
describe: 'Which images to build (all,strapi,base)', | ||
default: 'all', | ||
type: 'string', | ||
}) | ||
.option('push', { | ||
alias: 'p', | ||
describe: 'Should push the image after creating it', | ||
default: process.env.PUSH || false, | ||
type: 'boolean', | ||
}) | ||
.option('strapiVersion', { | ||
describe: 'strapi version to build', | ||
default: process.env.STRAPI_VERSION || 'latest', | ||
type: 'string', | ||
}) | ||
.version(false) | ||
.help('h') | ||
.alias('h', 'help').argv; | ||
|
||
if (argv.help) { | ||
yargs.showHelp(); | ||
return; | ||
} | ||
|
||
run().catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); | ||
|
||
function logImages(imgs) { | ||
console.log('---------------------------------------'); | ||
console.log('Images created:'); | ||
console.log(imgs.map(img => `- ${img}`).join('\n')); | ||
console.log('---------------------------------------'); | ||
} |
Oops, something went wrong.