build(docker): add docker builder
This commit is contained in:
6
.env.default
Normal file
6
.env.default
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
KEY_STORE=<keystore.jks>
|
||||||
|
KEY_PASS=<passphrase>
|
||||||
|
SDK_PATH=$HOME/sdk
|
||||||
|
PUBLISH_PATH=$HOME/public/puzzlez
|
||||||
|
BUILD_PATH=./build
|
||||||
|
TARGET_PATH=./target
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,3 +14,4 @@ config.json
|
|||||||
/log
|
/log
|
||||||
/ansible/*.retry
|
/ansible/*.retry
|
||||||
.npmrc
|
.npmrc
|
||||||
|
.env
|
||||||
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
FROM ubuntu:noble AS base
|
||||||
|
RUN apt update && apt install -y \
|
||||||
|
nodejs \
|
||||||
|
npm \
|
||||||
|
openjdk-11-jre \
|
||||||
|
protobuf-compiler \
|
||||||
|
jq
|
||||||
|
RUN node -v
|
||||||
|
RUN npm -v
|
||||||
|
|
||||||
|
FROM base AS builder
|
||||||
|
ENV GRADLE_USER_HOME=/sdk/gradle
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY gulpfile.js protohx.json ./
|
||||||
|
COPY tasks ./tasks
|
||||||
|
COPY config.example.json ./config.example.json
|
||||||
|
RUN --mount=type=secret,id=KEY_STORE \
|
||||||
|
cat /run/secrets/KEY_STORE > ./key.jks
|
||||||
|
RUN --mount=type=secret,id=KEY_PASS,env=KEY_PASS \
|
||||||
|
jq --arg key_pass "$KEY_PASS" \
|
||||||
|
'.SdkDir = "/sdk" | .PublishDir = "/app/publish" | .Key.store = "key.jks" | .Key.pass = $key_pass' \
|
||||||
|
config.example.json > config.json
|
||||||
|
COPY src ./src
|
||||||
|
COPY dependencies ./dependencies
|
||||||
|
VOLUME ["/sdk", "/app/build", "/app/target", "/app/publish", "/app/src-gen"]
|
||||||
|
CMD ["npx", "gulp", "default"]
|
||||||
22
docker-compose.yaml
Normal file
22
docker-compose.yaml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: puzzlez
|
||||||
|
services:
|
||||||
|
builder:
|
||||||
|
container_name: puzzlez-builder
|
||||||
|
image: infernal-games/puzzlez-builder
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
secrets:
|
||||||
|
- KEY_STORE
|
||||||
|
- KEY_PASS
|
||||||
|
volumes:
|
||||||
|
- ${SDK_PATH}:/sdk
|
||||||
|
- ${BUILD_PATH}:/app/build
|
||||||
|
- ${TARGET_PATH}:/app/target
|
||||||
|
- ${PUBLISH_PATH}:/app/publish
|
||||||
|
- ./src-gen:/app/src-gen
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
KEY_STORE:
|
||||||
|
file: $KEY_STORE
|
||||||
|
KEY_PASS:
|
||||||
|
environment: KEY_PASS
|
||||||
200
gulpfile.js
200
gulpfile.js
@@ -1,139 +1,139 @@
|
|||||||
const gulp = require('gulp');
|
const gulp = require("gulp");
|
||||||
const gulpClean = require('gulp-clean');
|
const gulpClean = require("gulp-clean");
|
||||||
const Config = require('./config.json');
|
const Config = require("./config.json");
|
||||||
const packageInfo = require('./package.json');
|
const packageInfo = require("./package.json");
|
||||||
const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
|
const { System, Sdk, Haxe, Project } = require("gulp-haxetool");
|
||||||
const dateformat = require('dateformat');
|
const dateformat = require("dateformat");
|
||||||
const argv = require('yargs').argv;
|
const publish = require("./tasks/gulp-publish");
|
||||||
const publish = require('./tasks/gulp-publish');
|
|
||||||
|
|
||||||
if (packageInfo.haxe) {
|
if (packageInfo.haxe) {
|
||||||
Haxe.VERSION = packageInfo.haxe;
|
Haxe.VERSION = packageInfo.haxe;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.SdkDir) {
|
if (Config.SdkDir) {
|
||||||
Sdk.dir = Config.SdkDir;
|
Sdk.dir = Config.SdkDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.BuildDir) {
|
if (Config.BuildDir) {
|
||||||
Haxe.buildDir = Config.BuildDir;
|
Haxe.buildDir = Config.BuildDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.clean = function clean() {
|
exports.clean = function clean() {
|
||||||
return gulp.src('target/*', {read: false}).pipe(gulpClean());
|
return gulp.src("target/*", { read: false }).pipe(gulpClean());
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.generate = function generate() {
|
exports.setup = function setup() {
|
||||||
return new Haxe().haxelib(['run', 'protohx', 'generate', 'protohx.json']).then(({stdout}) => {
|
const builder = Project.Builder.new(
|
||||||
if (stdout.indexOf('FAIL') > -1) {
|
app.config,
|
||||||
throw stdout;
|
Project.Platform.ANDROID,
|
||||||
|
app.buildSystem,
|
||||||
|
);
|
||||||
|
return builder.prepare();
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.generate = function generate() {
|
||||||
|
return exports.setup().then(() =>
|
||||||
|
new Haxe()
|
||||||
|
.haxelib(["run", "protohx", "generate", "protohx.json"])
|
||||||
|
.then(({ stdout }) => {
|
||||||
|
if (stdout.indexOf("FAIL") > -1) {
|
||||||
|
throw stdout;
|
||||||
}
|
}
|
||||||
});
|
}),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const config = new Project.Config({
|
const config = new Project.Config({
|
||||||
meta: {
|
meta: {
|
||||||
title: 'Puzzle\'z',
|
title: "Puzzle'z",
|
||||||
filename: 'puzzlez',
|
filename: "puzzlez",
|
||||||
icon: 'src/app/resources/icon.png',
|
icon: "src/app/resources/icon.png",
|
||||||
pack: 'ru.m.puzzlez',
|
pack: "ru.m.puzzlez",
|
||||||
author: 'shmyga <shmyga.z@gmail.com>',
|
author: "shmyga <shmyga.z@gmail.com>",
|
||||||
company: 'MegaLoMania',
|
company: "MegaLoMania",
|
||||||
version: packageInfo.version + (Config.Develop ? '-SNAPSHOT' : ''),
|
version: packageInfo.version + (Config.Develop ? "-SNAPSHOT" : ""),
|
||||||
},
|
},
|
||||||
key: Config.Key,
|
key: Config.Key,
|
||||||
libs: packageInfo.haxeDependencies,
|
libs: packageInfo.haxeDependencies,
|
||||||
macros: [
|
macros: [
|
||||||
`CompilationOption.set('build','${dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss')}')`,
|
`CompilationOption.set('build','${dateformat(new Date(), "yyyy-mm-dd HH:MM:ss")}')`,
|
||||||
`CompilationOption.set('UNSPLASH_KEY','${Config.UnsplashKey}')`,
|
`CompilationOption.set('UNSPLASH_KEY','${Config.UnsplashKey}')`,
|
||||||
`CompilationOption.set('PIXABAY_KEY','${Config.PixabayKey}')`,
|
`CompilationOption.set('PIXABAY_KEY','${Config.PixabayKey}')`,
|
||||||
],
|
],
|
||||||
flags: [
|
flags: ["proto_debug"],
|
||||||
'proto_debug',
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const app = new Project(
|
const app = new Project(
|
||||||
Project.BuildSystem.OPENFL,
|
Project.BuildSystem.OPENFL,
|
||||||
[
|
[
|
||||||
Project.Platform.FLASH,
|
Project.Platform.FLASH,
|
||||||
Project.Platform.HTML5,
|
Project.Platform.HTML5,
|
||||||
Project.Platform.LINUX,
|
Project.Platform.LINUX,
|
||||||
Project.Platform.WINDOWS,
|
Project.Platform.WINDOWS,
|
||||||
Project.Platform.ANDROID,
|
Project.Platform.ANDROID,
|
||||||
|
],
|
||||||
|
config.branch({
|
||||||
|
name: "app",
|
||||||
|
sources: ["src-gen/haxe", "src/common/haxe", "src/app/haxe"],
|
||||||
|
android: [
|
||||||
|
{
|
||||||
|
path: "dependencies/android",
|
||||||
|
extensions: ["ru.m.android.FileUtil"],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
config.branch({
|
assets: ["src/app/resources"],
|
||||||
name: 'app',
|
main: "ru.m.puzzlez.PuzzlezApp",
|
||||||
sources: [
|
meta: {
|
||||||
'src-gen/haxe',
|
width: 1280,
|
||||||
'src/common/haxe',
|
height: 768,
|
||||||
'src/app/haxe',
|
},
|
||||||
],
|
flags: ["app"],
|
||||||
android: [{
|
}),
|
||||||
path: 'dependencies/android',
|
|
||||||
extensions: ['ru.m.android.FileUtil'],
|
|
||||||
}],
|
|
||||||
assets: [
|
|
||||||
'src/app/resources',
|
|
||||||
],
|
|
||||||
main: 'ru.m.puzzlez.PuzzlezApp',
|
|
||||||
meta: {
|
|
||||||
width: 1280,
|
|
||||||
height: 768,
|
|
||||||
},
|
|
||||||
flags: [
|
|
||||||
'app',
|
|
||||||
]
|
|
||||||
}),
|
|
||||||
).bind(module, gulp);
|
).bind(module, gulp);
|
||||||
|
|
||||||
const server = new Project(
|
const server = new Project(
|
||||||
Project.BuildSystem.HAXE,
|
Project.BuildSystem.HAXE,
|
||||||
[
|
[Project.Platform.NEKO, Project.Platform.CPP],
|
||||||
Project.Platform.NEKO,
|
config.branch({
|
||||||
Project.Platform.CPP,
|
name: "server",
|
||||||
],
|
sources: ["src-gen/haxe", "src/common/haxe", "src/server/haxe"],
|
||||||
config.branch({
|
main: "ru.m.puzzlez.PuzzlezServer",
|
||||||
name: 'server',
|
}),
|
||||||
sources: [
|
|
||||||
'src-gen/haxe',
|
|
||||||
'src/common/haxe',
|
|
||||||
'src/server/haxe',
|
|
||||||
],
|
|
||||||
main: 'ru.m.puzzlez.PuzzlezServer',
|
|
||||||
})
|
|
||||||
).bind(module, gulp);
|
).bind(module, gulp);
|
||||||
|
|
||||||
module.exports.publish = publish(packageInfo.name, packageInfo.version, Config.PublishDir, Config.PublishUrl);
|
module.exports.publish = publish(
|
||||||
|
packageInfo.name,
|
||||||
|
packageInfo.version,
|
||||||
|
Config.PublishDir,
|
||||||
|
Config.PublishUrl,
|
||||||
|
);
|
||||||
|
|
||||||
const defaultSeries = [
|
const defaultSeries = [
|
||||||
exports.clean,
|
exports.clean,
|
||||||
exports.generate,
|
exports.generate,
|
||||||
module.exports['app:flash:build'],
|
module.exports["app:flash:build"],
|
||||||
module.exports['app:flash:html'],
|
module.exports["app:flash:html"],
|
||||||
module.exports['app:html5:build'],
|
module.exports["app:html5:build"],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (System.isLinux) {
|
if (System.isLinux) {
|
||||||
defaultSeries.push(
|
defaultSeries.push(
|
||||||
module.exports['app:linux:build'],
|
module.exports["app:linux:build"],
|
||||||
module.exports['app:linux:archive'],
|
module.exports["app:linux:archive"],
|
||||||
module.exports['app:linux:deb'],
|
module.exports["app:linux:deb"],
|
||||||
|
|
||||||
module.exports['app:android:build'],
|
module.exports["app:android:build"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (System.isWindows) {
|
if (System.isWindows) {
|
||||||
defaultSeries.push(
|
defaultSeries.push(
|
||||||
module.exports['app:windows:build'],
|
module.exports["app:windows:build"],
|
||||||
module.exports['app:windows:archive'],
|
module.exports["app:windows:archive"],
|
||||||
module.exports['app:windows:installer'],
|
module.exports["app:windows:installer"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultSeries.push(
|
defaultSeries.push(exports.publish);
|
||||||
exports.publish,
|
|
||||||
);
|
|
||||||
|
|
||||||
module.exports.default = gulp.series(defaultSeries);
|
module.exports.default = gulp.series(defaultSeries);
|
||||||
|
|||||||
7
scripts/build
Executable file
7
scripts/build
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname $(dirname "$0"))" || exit
|
||||||
|
|
||||||
|
source .env
|
||||||
|
mkdir -p "$SDK_PATH" "$PUBLISH_PATH" "$BUILD_PATH" "$TARGET_PATH"
|
||||||
|
docker compose run --rm --user $(id -u):$(id -g) --build --remove-orphans builder
|
||||||
Reference in New Issue
Block a user