diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..20996fb1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +docs/ +scripts/ +target/ + +*.md +CODEOWNERS diff --git a/.editorconfig b/.editorconfig index 4568d6f9..64b2b330 100644 --- a/.editorconfig +++ b/.editorconfig @@ -37,3 +37,7 @@ indent_size = 4 [*.{yaml,yml}] indent_style = space indent_size = 2 + +[Dockerfile] +indent_style = space +indent_size = 4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d8f22d49..9c834c5f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,3 +45,34 @@ jobs: uses: softprops/action-gh-release@v1 with: files: '*.tar.gz' + + docker: + name: Publish Docker Image + runs-on: ubuntu-latest + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v3 + - name: Login to ghcr + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract Metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and Publish + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..6393f37e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM rust:1-alpine3.18 +WORKDIR app +COPY . . +RUN apk --update add cmake make musl-dev pkgconfig && \ + cargo build --release && \ + cp target/release/gengo /usr/local/bin/gengo && \ + rm -rf target + +ENTRYPOINT ["gengo"] diff --git a/README.md b/README.md index e21901e5..6adc80d0 100644 --- a/README.md +++ b/README.md @@ -64,5 +64,14 @@ templates/*.js gengo-language=Plain-Text You will need to commit your `.gitattributes` file for it to take effect. +### Docker + +You can build a docker image and run it as well. + +```bash +docker build -t gengo . +docker run --rm -v $(pwd):$(pwd) -w $(pwd) -t gengo +``` + [linguist]: https://github.com/github-linguist/linguist [tokei]: https://github.com/xampprocky/tokei