From 774b012871b47d820242c65bd3478ef01d58053a Mon Sep 17 00:00:00 2001 From: Adam JOLY Date: Sat, 4 Jan 2025 17:58:17 +0100 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=E2=9C=A8=E3=80=8D=20feat:=20fuck=20ba?= =?UTF-8?q?sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.lock | 79 +++++++++++++++++++ flake.nix | 30 ++++++- srcs/requirements/mariadb/Dockerfile | 15 ++-- .../requirements/mariadb/docker-entrypoint.sh | 2 +- srcs/requirements/mariadb/docker.cnf | 14 ++++ srcs/requirements/mariadb/healthcheck.sh | 1 + srcs/requirements/nginx/docker-entrypoint.sh | 1 + 7 files changed, 130 insertions(+), 12 deletions(-) create mode 100644 flake.lock create mode 100644 srcs/requirements/mariadb/docker.cnf create mode 100644 srcs/requirements/mariadb/healthcheck.sh diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ec8fb4b --- /dev/null +++ b/flake.lock @@ -0,0 +1,79 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1733312601, + "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1735834308, + "narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "6df24922a1400241dae323af55f30e4318a6ca65", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1733096140, + "narHash": "sha256-1qRH7uAUsyQI7R1Uwl4T+XvdNv778H0Nb5njNrqvylY=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz" + } + }, + "pogit": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733518808, + "narHash": "sha256-tKqXoNTG1PGOnHjb6UvkSpKOZFDXDmZt1p0mw5Cic58=", + "owner": "y-syo", + "repo": "pogit", + "rev": "c3cb3fa9aefcf9e065ee27f2daa62a3826d48169", + "type": "github" + }, + "original": { + "owner": "y-syo", + "repo": "pogit", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "pogit": "pogit" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index 759c48a..1979005 100644 --- a/flake.nix +++ b/flake.nix @@ -1,9 +1,33 @@ { inputs = { - + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + pogit = { + url = "github:y-syo/pogit"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { + outputs = inputs@{ nixpkgs, ... }: + let + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { inherit system; }; + }); + in { + devShells = forEachSupportedSystem ({ pkgs }: { + default = pkgs.mkShell.override + {} + { + buildInputs = with pkgs;[ - }; + ]; + packages = with pkgs; [ + git + vault + inputs.pogit.packages.${pkgs.system}.default + ]; + }; + }); + }; } + diff --git a/srcs/requirements/mariadb/Dockerfile b/srcs/requirements/mariadb/Dockerfile index 66a209b..91efff5 100644 --- a/srcs/requirements/mariadb/Dockerfile +++ b/srcs/requirements/mariadb/Dockerfile @@ -4,21 +4,20 @@ LABEL version="0.1" LABEL maintainer="KeyZox" RUN groupadd --gid 999 -r mysql \ - && useradd -r -g mysql mysql --home-dir /var/lib/mysql --uid 999 + && useradd -r -g mysql mysql --home-dir /var/lib/mysql --uid 999 \ + && echo 'permit nopass root as mysql' >> /etc/doas.conf ENV LANG C.UTF-8 +COPY --chmod=0644 docker.cnf /etc/my.cnf.d/ + RUN set -x \ - && apk add --no-cache mariadb gosu tzdata \ - && gosu --version \ - && gosu nobody true \ + && apk add --no-cache mariadb tzdata doas \ VOLUME /var/lib/mysql -COPY healthcheck.sh /healthcheck.sh -COPY docker-entrypoint.sh /docker-entrypoint.sh -RUN [ "chmod", "+x", "/docker-entrypoint.sh" ] -RUN [ "chmod", "+x", "/healthcheck.sh" ] +COPY --chmod=0741 healthcheck.sh /healthcheck.sh +COPY --chmod=0741 docker-entrypoint.sh /docker-entrypoint.sh ENTRYPOINT [ "/docker-entrypoint.sh" ] WORKDIR /var/lib/mysql diff --git a/srcs/requirements/mariadb/docker-entrypoint.sh b/srcs/requirements/mariadb/docker-entrypoint.sh index 0daad14..214eb4c 100644 --- a/srcs/requirements/mariadb/docker-entrypoint.sh +++ b/srcs/requirements/mariadb/docker-entrypoint.sh @@ -1,3 +1,3 @@ #!/bin/sh -exec $@ +exec "$@" diff --git a/srcs/requirements/mariadb/docker.cnf b/srcs/requirements/mariadb/docker.cnf new file mode 100644 index 0000000..41dad70 --- /dev/null +++ b/srcs/requirements/mariadb/docker.cnf @@ -0,0 +1,14 @@ +# Ubuntu container compatibility + +[mariadb] +host-cache-size=0 +skip-name-resolve + +expire_logs_days=10 + + +[client-server] +socket=/run/mariadb/mariadb.sock + +!includedir /etc/mysql/mariadb.conf.d +!includedir /etc/mysql/conf.d diff --git a/srcs/requirements/mariadb/healthcheck.sh b/srcs/requirements/mariadb/healthcheck.sh new file mode 100644 index 0000000..1a24852 --- /dev/null +++ b/srcs/requirements/mariadb/healthcheck.sh @@ -0,0 +1 @@ +#!/bin/sh diff --git a/srcs/requirements/nginx/docker-entrypoint.sh b/srcs/requirements/nginx/docker-entrypoint.sh index 214eb4c..8959ebc 100644 --- a/srcs/requirements/nginx/docker-entrypoint.sh +++ b/srcs/requirements/nginx/docker-entrypoint.sh @@ -1,3 +1,4 @@ #!/bin/sh +set -e exec "$@"