Skip to content

Commit c318c9b

Browse files
committed
Merge branch 'docker'
2 parents 86348d1 + d5765e8 commit c318c9b

File tree

7 files changed

+107
-0
lines changed

7 files changed

+107
-0
lines changed

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*
2+
!bin/
3+
!docs/
4+
!src/
5+
!templates/
6+
!composer.json
7+
!Dockerfile
8+
!Docker.README.md
9+
!LICENSE
10+
!README.md

.github/workflows/docker.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: docker
2+
on:
3+
workflow_dispatch:
4+
release:
5+
branches: [ "master" ]
6+
types: [ "published" ]
7+
tags: [ "v*" ]
8+
9+
# Actions
10+
# docker/setup-buildx-action@v3 https://github.com/marketplace/actions/docker-setup-buildx
11+
# docker/login-action@v3 https://github.com/marketplace/actions/docker-login
12+
# docker/metadata-action@v5 https://github.com/marketplace/actions/docker-metadata-action
13+
# docker/build-push-action@v6 https://github.com/marketplace/actions/build-and-push-docker-images
14+
15+
jobs:
16+
docker:
17+
name: Docker image
18+
runs-on: "ubuntu-latest"
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
- name: Set application version
23+
run: sed -i "s#@box_git_version@#${{ github.ref_name }}#" bin/*
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
- name: Login to Docker Hub
27+
uses: docker/login-action@v3
28+
with:
29+
username: ${{ secrets.DOCKERHUB_USERNAME }}
30+
password: ${{ secrets.DOCKERHUB_TOKEN }}
31+
- name: Extract metadata for Docker
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: "${{ github.repository }}"
36+
tags: "type=semver,pattern={{version}}"
37+
- name: Build and push
38+
uses: docker/build-push-action@v6
39+
with:
40+
context: .
41+
push: true
42+
tags: ${{ steps.meta.outputs.tags }}
43+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: "Create and publish Phar"
22

33
on:
4+
workflow_dispatch:
45
release:
56
branches: [ "master" ]
67
types: [ "published" ]

Docker.README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# phpcfdi/cfditopdf dockerfile helper
2+
3+
```shell script
4+
# get the project repository on folder "cfditopdf"
5+
git clone https://github.com/phpcfdi/cfditopdf.git cfditopdf
6+
7+
# build the image "cfditopdf" from folder "cfditopdf/"
8+
docker build --tag cfditopdf cfditopdf/
9+
10+
# remove image cfditopdf
11+
docker rmi cfditopdf
12+
```
13+
14+
## Run command
15+
16+
The project is installed on `/opt/source/` and the entry point is the command
17+
`/usr/local/bin/php /opt/source/bin/cfditopdf`.
18+
19+
```shell
20+
# show help
21+
docker run -it --rm --user="$(id -u):$(id -g)" cfditopdf --help
22+
23+
# montar un volumen para ejecutar una conversión
24+
docker run -it --rm --user="$(id -u):$(id -g)" --volume="${PWD}/files:/files" \
25+
cfditopdf /files/cfdis/F-12345.xml /files/pdfs/F-12345.pdf
26+
```

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM php:8.4-cli-alpine
2+
3+
COPY . /opt/source
4+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
5+
6+
# install git, ext-zip and ext-xsl and ext-gd
7+
RUN apk add git libzip libxslt freetype libjpeg-turbo libpng \
8+
libzip-dev libxslt-dev freetype-dev libjpeg-turbo-dev libpng-dev libzip-dev libxslt-dev && \
9+
docker-php-ext-install zip xsl gd && \
10+
apk del libzip-dev libxslt-dev freetype-dev libjpeg-turbo-dev libpng-dev libzip-dev libxslt-dev
11+
12+
# build project
13+
RUN cd /opt/source && \
14+
rm -r -f composer.lock vendor && \
15+
composer update --no-dev && \
16+
composer check-platform-reqs
17+
18+
ENTRYPOINT ["/usr/local/bin/php", "/opt/source/bin/cfditopdf"]

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ $ bin/cfditopdf [options] <cfdi-file> [<pdf-file>]
3737
".xml" extension and suffix ".pdf" extension
3838
```
3939

40+
## Basic usage from docker
41+
42+
```shell
43+
docker run -it --rm --user="$(id -u):$(id -g)" cfditopdf --help
44+
```
45+
46+
See more information on the [Docker README](Docker.README.md) file.
47+
4048
## Basic usage as a PHP library
4149

4250
```php

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Fix compatibility with PHP 8.4.
66
- Allow dependence of `eclipxe/cfdiutils` to match versions `^2.31` and `^3.0`.
77
- Update license year to 2025.
8+
- Add Docker Hub public image. Thanks to `@dreglad` for the inspiration.
89

910
These changes apply to the development environment:
1011

0 commit comments

Comments
 (0)