6 Commits

13 changed files with 69 additions and 91 deletions

6
.dockerignore Normal file
View File

@@ -0,0 +1,6 @@
**
!src
!Cargo.toml
!Cargo.lock
!flake.nix
!flake.lock

View File

@@ -2,9 +2,7 @@ name: Docker
on:
push:
branches: ["main"]
paths:
- "Cargo.toml"
branches: ["main", "feature/docker"]
pull_request:
branches: ["main"]
@@ -14,29 +12,12 @@ env:
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: hustcer/setup-nu@v3
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix build .#docker
- run: |
export CARGO_VERSION=$(nu -c "cargo metadata --format-version=1 --no-deps | from json | get packages | first | get version")
echo "CARGO_VERSION=$CARGO_VERSION" >> $GITHUB_ENV
- run: docker load -i result
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- run: docker tag docki:latest "ghcr.io/quirinecker/docki:$CARGO_VERSION"
- run: docker tag docki:latest "ghcr.io/quirinecker/docki:latest"
- run: docker push ghcr.io/quirinecker/docki:$CARGO_VERSION
- run: docker push ghcr.io/quirinecker/docki:latest
- name: Get Cargo version
run: version=$(nu -c "cargo metadata --format-version=1 --no-deps | from json | get packages | first | get version")
- name: Build docker image
run: docker build -t docki:$version .

20
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,20 @@
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
default:
image: 'quirinecker/rust-openssl'
build:
script:
- cargo build
test:
script:
- cargo test
# publish:
# script:
# - export CARGO_REGISTRY_TOKEN=$CARGO_TOKEN
# - cargo publish

View File

Before

Width:  |  Height:  |  Size: 18 MiB

After

Width:  |  Height:  |  Size: 18 MiB

2
Cargo.lock generated
View File

@@ -859,7 +859,7 @@ checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
[[package]]
name = "docki"
version = "1.2.2"
version = "1.2.1"
dependencies = [
"bytes",
"clap 4.1.8",

View File

@@ -1,11 +1,13 @@
[package]
name = "docki"
version = "1.2.2"
version = "1.2.1"
edition = "2021"
description = "cli for building and publishing documentation using asciidoctor"
license-file = "LICENSE.txt"
authors = ["Quirin Ecker"]
exclude = [".gitlab", ".github"]
exclude = [
".gitlab"
]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

11
Dockerfile Normal file
View File

@@ -0,0 +1,11 @@
FROM nixos/nix AS build
WORKDIR /app
COPY . /app
RUN nix --extra-experimental-features nix-command --extra-experimental-features flakes build \
&& nix --extra-experimental-features nix-command --extra-experimental-features flakes store gc
RUN mkdir /out && cp result/bin/docki .

View File

@@ -6,7 +6,7 @@
## Preview
![screencast](.github/assets/screencast.gif)
![screencast](.gitlab/screencast.gif)
Docki is cli for converting asciidoctor files into html files.
@@ -29,26 +29,29 @@ docki serve
## Installation
### Homebrew
### Nix
This installation method is recommended, because it will include both asciidoctor and asciidoctor_revealjs.
Note: This is the most basic installation. If you are already more experienced, you might want to add it to your shell or home manager configuration.
```shell
brew tap quirinecker/homebrew-docki https://github.com/quirinecker/homebrew-docki
nix profile install github:quirinecker/docki
```
### Homebrew
> [!NOTE]
> Installing it via homebrew will not include asciidoctor_revealjs. It can be installed afterwards with `docki install-reveal`
```shell
brew tap quirinecker/docki-homebrew https://github.com/quirinecker/docki-homebrew
```
```
brew install docki
```
### Nix
If you just want to try it out real quick and the nix package manager is available on your system you can use the following command.
```shell
nix develop github:quirinecker/docki#preview
```
This will open a shell evnironment with docki installed. If you want to install it permanently with nix, i would recommend following the instructions in the [Nix (Advanced, Flake)](#nix-advanced-flake) section.
### Cargo
> [!NOTE]
@@ -58,19 +61,6 @@ This will open a shell evnironment with docki installed. If you want to install
cargo install docki
```
### Docker
There is also a docker image available to use. It is primarily used for the gh actions.
```shell
docker pull ghcr.io/quirinecker/docki:latest
```
You can also build it yourself with nix.
```
nix build .#docker && docker load -i result
```
### Nix (Advanced, Flake)

View File

@@ -120,26 +120,6 @@
naerskLib = naerskLib;
pkgs = pkgs;
};
docker = pkgs.dockerTools.buildImage {
name = "docki";
tag = "latest";
config = {
WorkingDir = "/app";
};
copyToRoot = pkgs.buildEnv {
name = "docki-docker";
paths = [
pkgs.coreutils
pkgs.bash
pkgs.cacert
(build_docki {
naerskLib = naerskLib;
pkgs = pkgs;
})
];
};
};
}
);
};

View File

@@ -1,11 +0,0 @@
= My cool presentation
:author: John Doe
:email: john@doe.com
== First slide
Content
== Second slide
Content

View File

@@ -39,12 +39,11 @@ impl BuildExecution {
async fn prepare() -> Result<(), String> {
let reveal_version = "5.2.1";
let reveal_version = "3.9.2";
let target = format!("https://github.com/hakimel/reveal.js/archive/{reveal_version}.zip");
create_dir_recursive("./docs/slides");
let response = reqwest::get(target.clone()).await.unwrap();
let Ok(response) = reqwest::get(target).await else {
return Err("could not downlaod revealjs".to_string())
};

View File

@@ -59,12 +59,12 @@ fn build_file(paths: Vec<std::path::PathBuf>) {
let in_path = paths
.first()
.expect(invalid_path_message)
.strip_prefix(&current_dir())
.expect(invalid_path_message)
.to_str()
.expect(invalid_path_message);
.expect(invalid_path_message)
.replace(&current_dir(), "")
.replace("/./", "./");
let in_path = format!("./{}", in_path);
let result = docki_build(&in_path);
match result {

View File

@@ -5,5 +5,5 @@ fn test_fetch_asciidoctor_paths_recursive() {
let paths = fs_util::fetch_paths_recursive("res/test/docs").unwrap();
let len = paths.len();
dbg!(paths);
assert_eq!(len, 6);
assert_eq!(len, 5);
}