mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
nix based docker
This commit is contained in:
parent
7dbb41a5d0
commit
1b3ca59a46
11 changed files with 672 additions and 1011 deletions
30
.github/workflows/ci.yaml
vendored
30
.github/workflows/ci.yaml
vendored
|
|
@ -115,3 +115,33 @@ jobs:
|
|||
BASE_URL: http://nginx
|
||||
EDIT_KEY: edit
|
||||
uses: docker://demostf/api-test
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v25
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build
|
||||
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build, api, phpunit]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v25
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build .#docker
|
||||
- name: Push image
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
skopeo copy --dest-creds="${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_TOKEN }}" "docker-archive:$(nix build .#docker --print-out-paths)" "docker://demostf/proxy"
|
||||
|
|
|
|||
29
.github/workflows/docker.yaml
vendored
29
.github/workflows/docker.yaml
vendored
|
|
@ -1,29 +0,0 @@
|
|||
name: docker-build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
repository_dispatch:
|
||||
types: [ build ]
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
tags: demostf/api:latest
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
{
|
||||
"name": "demostf/api",
|
||||
"description": "api implementation for demos.tf",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"mikecao/flight": "1.3.8",
|
||||
"vlucas/phpdotenv": "^v5.4.1",
|
||||
|
|
@ -12,7 +15,7 @@
|
|||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "git",
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/koraktor/steam-condenser-php"
|
||||
}
|
||||
],
|
||||
|
|
|
|||
1449
composer.lock
generated
1449
composer.lock
generated
File diff suppressed because it is too large
Load diff
53
docker.nix
Normal file
53
docker.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
demostf-api,
|
||||
demostf-parser,
|
||||
php,
|
||||
runtimeShell,
|
||||
writeScriptBin,
|
||||
fakeNss,
|
||||
coreutils-full,
|
||||
bash,
|
||||
dockerTools
|
||||
}: let
|
||||
phpWithExtensions = php.buildEnv {
|
||||
extensions = ({ enabled, all }: enabled ++ (with all; [pdo apcu]));
|
||||
extraConfig = ''
|
||||
post_max_size = 150M
|
||||
upload_max_filesize = 150M
|
||||
'';
|
||||
};
|
||||
in dockerTools.buildLayeredImage {
|
||||
name = "demostf/api";
|
||||
tag = "latest";
|
||||
maxLayers = 10;
|
||||
|
||||
contents = [
|
||||
demostf-api
|
||||
demostf-parser
|
||||
phpWithExtensions
|
||||
dockerTools.caCertificates
|
||||
coreutils-full
|
||||
bash
|
||||
fakeNss
|
||||
(writeScriptBin "start-server" ''
|
||||
#!${runtimeShell}
|
||||
php-fpm -F -y ${./php-fpm.conf}
|
||||
'')
|
||||
];
|
||||
|
||||
extraCommands = ''
|
||||
mkdir -p tmp
|
||||
chmod 1777 tmp
|
||||
ln -s ${demostf-api}/share/php/demostf-api app
|
||||
'';
|
||||
|
||||
config = {
|
||||
Cmd = [ "start-server" ];
|
||||
Env = [
|
||||
"PARSER_PATH=${demostf-parser}/bin/parse_demo"
|
||||
];
|
||||
ExposedPorts = {
|
||||
"9000/tcp" = {};
|
||||
};
|
||||
};
|
||||
}
|
||||
34
flake.lock
generated
34
flake.lock
generated
|
|
@ -2,16 +2,16 @@
|
|||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1674902473,
|
||||
"narHash": "sha256-MdKJeeDTjCtmoVPWLEDg10jgknt6rqTO3c1WeNQtho4=",
|
||||
"lastModified": 1710523508,
|
||||
"narHash": "sha256-cyaeYdWG+RQOFPn1DHgO/lerVI4dxHWwF4EJ0dYcu5g=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "548896f4d9f7db2f7205d82727d6c03c86d2f896",
|
||||
"rev": "a3b22bfd2906b8c028d115f2ab4a1cc4ac806a9d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "release-22.11",
|
||||
"ref": "release-23.11",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
|
|
@ -21,13 +21,31 @@
|
|||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
|||
16
flake.nix
16
flake.nix
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/release-22.11";
|
||||
nixpkgs.url = "nixpkgs/release-23.11";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
|
|
@ -10,16 +10,24 @@
|
|||
utils,
|
||||
}:
|
||||
utils.lib.eachDefaultSystem (system: let
|
||||
overlays = [
|
||||
(import ./overlay.nix)
|
||||
];
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
inherit system overlays;
|
||||
};
|
||||
npmLd = pkgs.writeShellScriptBin "npm" ''
|
||||
PATH="$PATH ${pkgs.nodejs-16_x}/bin" LD=$CC ${pkgs.nodejs-16_x}/bin/npm $@
|
||||
PATH="$PATH ${pkgs.nodejs_20}/bin" LD=$CC ${pkgs.nodejs_20}/bin/npm $@
|
||||
'';
|
||||
nodeLd = pkgs.writeShellScriptBin "node" ''
|
||||
LD=$CC ${pkgs.nodejs-16_x}/bin/node $@
|
||||
LD=$CC ${pkgs.nodejs_20}/bin/node $@
|
||||
'';
|
||||
in rec {
|
||||
packages = rec {
|
||||
inherit (pkgs) demostf-api demostf-api-docker demostf-parser;
|
||||
docker = demostf-api-docker;
|
||||
default = demostf-api;
|
||||
};
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
gnumake
|
||||
|
|
|
|||
5
overlay.nix
Normal file
5
overlay.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
final: prev: {
|
||||
demostf-parser = final.callPackage ./parser.nix {};
|
||||
demostf-api = final.callPackage ./package.nix {};
|
||||
demostf-api-docker = final.callPackage ./docker.nix {};
|
||||
}
|
||||
20
package.nix
Normal file
20
package.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
stdenv,
|
||||
php,
|
||||
lib,
|
||||
}: let
|
||||
inherit (lib.sources) sourceByRegex;
|
||||
phpWithExtensions = php.withExtensions ({ enabled, all }: enabled ++ (with all; [pdo apcu]));
|
||||
in
|
||||
phpWithExtensions.buildComposerProject (finalAttrs: {
|
||||
pname = "demostf-api";
|
||||
version = "0.1.0";
|
||||
|
||||
src = sourceByRegex ./. ["composer.*" "(src|test)(/.*)?"];
|
||||
|
||||
vendorHash = "sha256-ympq8XIdABkdjshYX7hJIO6XfFdYm0RA9s3f/n7om3I=";
|
||||
|
||||
composerStrictValidation = false;
|
||||
|
||||
doCheck = false;
|
||||
})
|
||||
21
parser.nix
Normal file
21
parser.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
stdenv,
|
||||
rustPlatform,
|
||||
fetchFromGitHub,
|
||||
lib,
|
||||
}: let
|
||||
inherit (lib.sources) sourceByRegex;
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "demostf-parser";
|
||||
version = "0.1.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "demostf";
|
||||
repo = "parser";
|
||||
rev = "v0.4.0";
|
||||
hash = "sha256-/1D5bNnJWRwuycaLidSyuYC36IHSnyA33HvcoUH4GpI=";
|
||||
};
|
||||
|
||||
cargoSha256 = "sha256-UNslB5yKcVbuRELxbKQ1Bl2jHKoC3i0OEYq0UzTi1aU=";
|
||||
}
|
||||
23
php-fpm.conf
23
php-fpm.conf
|
|
@ -1,6 +1,19 @@
|
|||
[global]
|
||||
log_limit = 8192
|
||||
error_log = /proc/self/fd/2
|
||||
daemonize = no
|
||||
|
||||
[www]
|
||||
user = nobody
|
||||
group = nobody
|
||||
catch_workers_output = yes
|
||||
|
||||
clear_env = no
|
||||
pm = dynamic;
|
||||
pm.max_children = 250;
|
||||
pm.start_servers = 75;
|
||||
pm.min_spare_servers = 50;
|
||||
pm.max_spare_servers = 200;
|
||||
pm = dynamic
|
||||
pm.max_children = 250
|
||||
pm.start_servers = 75
|
||||
pm.min_spare_servers = 50
|
||||
pm.max_spare_servers = 200
|
||||
access.log = /proc/self/fd/2
|
||||
listen = 9000
|
||||
access.log = /proc/self/fd/2
|
||||
Loading…
Add table
Add a link
Reference in a new issue