1 Commits

Author SHA1 Message Date
e8e7897d86 build(docker): add docker builder 2026-04-06 11:55:29 +03:00
6 changed files with 164 additions and 100 deletions

6
.env.default Normal file
View 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
View File

@@ -14,3 +14,4 @@ config.json
/log
/ansible/*.retry
.npmrc
.env

28
Dockerfile Normal file
View 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
View 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

View File

@@ -1,139 +1,139 @@
const gulp = require('gulp');
const gulpClean = require('gulp-clean');
const Config = require('./config.json');
const packageInfo = require('./package.json');
const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
const dateformat = require('dateformat');
const argv = require('yargs').argv;
const publish = require('./tasks/gulp-publish');
const gulp = require("gulp");
const gulpClean = require("gulp-clean");
const Config = require("./config.json");
const packageInfo = require("./package.json");
const { System, Sdk, Haxe, Project } = require("gulp-haxetool");
const dateformat = require("dateformat");
const publish = require("./tasks/gulp-publish");
if (packageInfo.haxe) {
Haxe.VERSION = packageInfo.haxe;
Haxe.VERSION = packageInfo.haxe;
}
if (Config.SdkDir) {
Sdk.dir = Config.SdkDir;
Sdk.dir = Config.SdkDir;
}
if (Config.BuildDir) {
Haxe.buildDir = Config.BuildDir;
Haxe.buildDir = Config.BuildDir;
}
exports.clean = function clean() {
return gulp.src('target/*', {read: false}).pipe(gulpClean());
return gulp.src("target/*", { read: false }).pipe(gulpClean());
};
exports.generate = function generate() {
return new Haxe().haxelib(['run', 'protohx', 'generate', 'protohx.json']).then(({stdout}) => {
if (stdout.indexOf('FAIL') > -1) {
throw stdout;
exports.setup = function setup() {
const builder = Project.Builder.new(
app.config,
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({
meta: {
title: 'Puzzle\'z',
filename: 'puzzlez',
icon: 'src/app/resources/icon.png',
pack: 'ru.m.puzzlez',
author: 'shmyga <shmyga.z@gmail.com>',
company: 'MegaLoMania',
version: packageInfo.version + (Config.Develop ? '-SNAPSHOT' : ''),
},
key: Config.Key,
libs: packageInfo.haxeDependencies,
macros: [
`CompilationOption.set('build','${dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss')}')`,
`CompilationOption.set('UNSPLASH_KEY','${Config.UnsplashKey}')`,
`CompilationOption.set('PIXABAY_KEY','${Config.PixabayKey}')`,
],
flags: [
'proto_debug',
]
meta: {
title: "Puzzle'z",
filename: "puzzlez",
icon: "src/app/resources/icon.png",
pack: "ru.m.puzzlez",
author: "shmyga <shmyga.z@gmail.com>",
company: "MegaLoMania",
version: packageInfo.version + (Config.Develop ? "-SNAPSHOT" : ""),
},
key: Config.Key,
libs: packageInfo.haxeDependencies,
macros: [
`CompilationOption.set('build','${dateformat(new Date(), "yyyy-mm-dd HH:MM:ss")}')`,
`CompilationOption.set('UNSPLASH_KEY','${Config.UnsplashKey}')`,
`CompilationOption.set('PIXABAY_KEY','${Config.PixabayKey}')`,
],
flags: ["proto_debug"],
});
const app = new Project(
Project.BuildSystem.OPENFL,
[
Project.Platform.FLASH,
Project.Platform.HTML5,
Project.Platform.LINUX,
Project.Platform.WINDOWS,
Project.Platform.ANDROID,
Project.BuildSystem.OPENFL,
[
Project.Platform.FLASH,
Project.Platform.HTML5,
Project.Platform.LINUX,
Project.Platform.WINDOWS,
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({
name: 'app',
sources: [
'src-gen/haxe',
'src/common/haxe',
'src/app/haxe',
],
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',
]
}),
assets: ["src/app/resources"],
main: "ru.m.puzzlez.PuzzlezApp",
meta: {
width: 1280,
height: 768,
},
flags: ["app"],
}),
).bind(module, gulp);
const server = new Project(
Project.BuildSystem.HAXE,
[
Project.Platform.NEKO,
Project.Platform.CPP,
],
config.branch({
name: 'server',
sources: [
'src-gen/haxe',
'src/common/haxe',
'src/server/haxe',
],
main: 'ru.m.puzzlez.PuzzlezServer',
})
Project.BuildSystem.HAXE,
[Project.Platform.NEKO, Project.Platform.CPP],
config.branch({
name: "server",
sources: ["src-gen/haxe", "src/common/haxe", "src/server/haxe"],
main: "ru.m.puzzlez.PuzzlezServer",
}),
).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 = [
exports.clean,
exports.generate,
module.exports['app:flash:build'],
module.exports['app:flash:html'],
module.exports['app:html5:build'],
exports.clean,
exports.generate,
module.exports["app:flash:build"],
module.exports["app:flash:html"],
module.exports["app:html5:build"],
];
if (System.isLinux) {
defaultSeries.push(
module.exports['app:linux:build'],
module.exports['app:linux:archive'],
module.exports['app:linux:deb'],
defaultSeries.push(
module.exports["app:linux:build"],
module.exports["app:linux:archive"],
module.exports["app:linux:deb"],
module.exports['app:android:build'],
);
module.exports["app:android:build"],
);
}
if (System.isWindows) {
defaultSeries.push(
module.exports['app:windows:build'],
module.exports['app:windows:archive'],
module.exports['app:windows:installer'],
);
defaultSeries.push(
module.exports["app:windows:build"],
module.exports["app:windows:archive"],
module.exports["app:windows:installer"],
);
}
defaultSeries.push(
exports.publish,
);
defaultSeries.push(exports.publish);
module.exports.default = gulp.series(defaultSeries);

7
scripts/build Executable file
View 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" "src-gen"
docker compose run --rm --user $(id -u):$(id -g) --build --remove-orphans builder