Skip to content

Commit

Permalink
fix(ci): automatically build docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkolenz committed Jun 29, 2023
1 parent be3f90e commit 9bbdc77
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 33 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- uses: DeterminateSystems/nix-installer-action@v4
with:
extra-conf: |
extra-platforms = aarch64-linux
- uses: DeterminateSystems/magic-nix-cache-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- run: nix profile install .#releaseEnv
- uses: cihelper/action-semanticrelease-poetry@v1
id: semanticrelease
- uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ steps.semanticrelease.outputs.released == 'true' }}
- run: nix run .#dockerManifest --impure
if: ${{ steps.semanticrelease.outputs.released == 'true' }}
env:
VERSION: ${{ steps.semanticrelease.outputs.version }}
28 changes: 0 additions & 28 deletions .github/workflows/release.yml

This file was deleted.

13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ We will discuss the client at the end of this README.

## Installation and Setup

We are using `nix` and `poetry` to manage the dependencies.
We will soon provide a pre-built docker image for simplify usage of the NLP service.
We are using `nix` and `poetry` to manage the dependencies and provide a ready-to-use Docker image.

### Nix (recommended)
### Docker (recommended)

The container caches the downloaded models, so you should not pass `--rm` to `docker run`.

```sh
docker run ghcr.io/recap-utr/nlp-service:latest "0.0.0.0:50100"
```

### Nix (advanced)

```sh
nix run . -- "127.0.0.1:50100"
Expand Down
79 changes: 77 additions & 2 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
flocken = {
url = "github:mirkolenz/flocken/v1";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ {
self,
nixpkgs,
flake-parts,
systems,
poetry2nix,
flocken,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
Expand All @@ -27,6 +33,15 @@
python = pkgs.python310;
poetry = pkgs.poetry;
in {
apps.dockerManifest = {
type = "app";
program = lib.getExe (flocken.legacyPackages.${system}.mkDockerManifest {
branch = builtins.getEnv "GITHUB_REF_NAME";
name = "ghcr.io/" + builtins.getEnv "GITHUB_REPOSITORY";
version = builtins.getEnv "VERSION";
images = with self.packages; [x86_64-linux.docker];
});
};
packages = {
default = poetry2nix.legacyPackages.${system}.mkPoetryApplication {
inherit python;
Expand All @@ -47,6 +62,10 @@
cmd = ["0.0.0.0:50100"];
};
};
releaseEnv = pkgs.buildEnv {
name = "release-env";
paths = [poetry python];
};
};
devShells.default = pkgs.mkShell {
packages = [poetry python];
Expand Down

0 comments on commit 9bbdc77

Please sign in to comment.