diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml new file mode 100644 index 0000000..39aa3df --- /dev/null +++ b/.github/workflows/action.yml @@ -0,0 +1,34 @@ +name: Docker Action + +on: + pull_request: + push: + branches: + - action + +env: + CI_PROJECT_PATH: vatger-nav/mapbuilder + +jobs: + image: + name: Docker Image + runs-on: ubuntu-latest + permissions: write-all + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - name: Log in to the Container registry + uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build Docker images + run: nix build -L .#docker + - name: Push Docker images + run: | + if [ "$GITHUB_EVENT_NAME" != "pull_request" ]; then + skopeo copy --insecure-policy docker-archive://$(readlink -f ./result) docker://ghcr.io/$CI_PROJECT_PATH:$GITHUB_SHA + skopeo copy --insecure-policy docker-archive://$(readlink -f ./result) docker://ghcr.io/$CI_PROJECT_PATH:$GITHUB_REF_NAME + fi diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..028de0a --- /dev/null +++ b/action.yml @@ -0,0 +1,15 @@ +--- +name: 'mapbuilder' +author: 'vatger-nav' +description: 'Builder for GRPlugin and Topsky maps' +runs: + using: 'docker' + image: 'docker://ghcr.io/vatger-nav/mapbuilder:main' + args: + - '--debug' + - '-s' + - '/github/workspace/mapdata' + - '/github/workspace' +branding: + icon: 'map' + color: 'green' diff --git a/flake.nix b/flake.nix index 20dfd44..58e54eb 100644 --- a/flake.nix +++ b/flake.nix @@ -55,19 +55,40 @@ packages.default = poetry2nix.mkPoetryApplication { inherit overrides; projectDir = ./.; + checkGroups = []; }; - devShells.default = devEnv.env.overrideAttrs (attrs: { - nativeBuildInputs = attrs.nativeBuildInputs ++ [ - pkgs.poetry - pkgs.nil - pkgs.pyright + packages.docker = pkgs.dockerTools.buildLayeredImage { + name = "ghcr.io/vatger-nav/mapbuilder"; + tag = "latest"; + + contents = with pkgs; [ + cacert + tzdata + self'.packages.default ]; - shellHook = '' - export PYTHONPATH=${devEnv}/${devEnv.sitePackages} - ''; - }); - formatter = pkgs.nixfmt-rfc-style; - }; + + config = { + Env = [ + "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" + "PYTHONDONTWRITEBYTECODE=1" + "PYTHONUNBUFFERED=1" + ]; + WorkingDir = "/"; + Entrypoint = [ "mapbuilder" ]; + }; + }; + devShells.default = devEnv.env.overrideAttrs (attrs: { + nativeBuildInputs = attrs.nativeBuildInputs ++ [ + pkgs.poetry + pkgs.nil + pkgs.pyright + ]; + shellHook = '' + export PYTHONPATH=${devEnv}/${devEnv.sitePackages} + ''; + }); + formatter = pkgs.nixfmt-rfc-style; + }; } ); }