Skip to content

Commit ed73f61

Browse files
Merge pull request #132 from FREVA-CLINT/no-ansible-runner
No ansible runner
2 parents 32350fc + 4203046 commit ed73f61

File tree

22 files changed

+815
-365
lines changed

22 files changed

+815
-365
lines changed

.github/workflows/build_containers.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,19 @@ jobs:
4040
-
4141
name: Set up QEMU
4242
uses: docker/setup-qemu-action@v2
43-
43+
with:
44+
platforms: all
4445
-
4546
name: Set up Docker Buildx
4647
uses: docker/setup-buildx-action@v2
47-
48+
with:
49+
install: true
50+
-
51+
name: Create Buildx builder
52+
run: docker buildx create --use --name mybuilder --driver docker-container
53+
-
54+
name: Inspect Buildx builder
55+
run: docker buildx inspect --bootstrap
4856
-
4957
name: Log in to the Container registry
5058
uses: docker/login-action@v2
@@ -61,7 +69,7 @@ jobs:
6169
tags: |
6270
ghcr.io/freva-clint/freva-deployment:${{ steps.repository.outputs.tag }}
6371
ghcr.io/freva-clint/freva-deployment:latest
64-
platforms: linux/amd64,linux/arm64,linux/arm/v7
72+
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/i386
6573

6674
build-and-push-vault-image:
6775
runs-on: ubuntu-latest
@@ -86,12 +94,21 @@ jobs:
8694
echo "tag=$(python src/freva_deployment/__init__.py -v)" >> $GITHUB_OUTPUT
8795
-
8896
name: Set up QEMU
89-
uses: docker/setup-qemu-action@v1
90-
97+
uses: docker/setup-qemu-action@v2
98+
with:
99+
platforms: all
91100
-
92101
name: Set up Docker Buildx
93-
uses: docker/setup-buildx-action@v1
102+
uses: docker/setup-buildx-action@v2
103+
with:
104+
install: true
105+
-
106+
name: Create Buildx builder
107+
run: docker buildx create --use --name mybuilder --driver docker-container
94108

109+
-
110+
name: Inspect Buildx builder
111+
run: docker buildx inspect --bootstrap
95112
-
96113
name: Log in to the Container registry
97114
uses: docker/login-action@v2
@@ -104,7 +121,7 @@ jobs:
104121
uses: docker/build-push-action@v4
105122
with:
106123
context: assets/share/freva/deployment/vault/
107-
platforms: linux/amd64
124+
platforms: linux/amd64,linux/arm64
108125
push: true
109126
build-args: VERSION=${{steps.repository.outputs.tag}}
110127
tags: |

.github/workflows/build_job.yml

Lines changed: 184 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,163 @@
1-
name: Create a new release
2-
run-name: ${{ github.actor }} creating a new release 🧉
1+
name: Build binary & Create release
2+
run-name: ${{ github.actor }} building the pyinstaller binary and creating the release 🧉
33

4-
# Set the access for individual scopes, or use permissions: write-all
54
permissions:
65
pull-requests: write
76
contents: write
87
packages: write
98

109
on:
1110
push:
11+
branches: ["**"]
1212
tags:
1313
- "v*.*.*"
1414

1515
jobs:
1616
tests:
1717
uses: ./.github/workflows/ci_job.yml
18+
build-no-linux:
19+
name: Build packages
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
matrix:
23+
include:
24+
- os: macos-12
25+
target: osx-x64
26+
arch: x86_64
27+
py_arch: x64
28+
asset_mime: application/octet-stream
29+
exe: deploy-freva
30+
hidden_import: --hidden-import curses --hidden-import cowsay
31+
extra_pkg: cryptography
32+
- os: macos-14
33+
target: osx-arm64
34+
arch: arm64
35+
py_arch: arm64
36+
asset_mime: application/octet-stream
37+
exe: deploy-freva
38+
hidden_import: --hidden-import curses --hidden-import cowsay
39+
extra_pkg: cryptography
40+
- os: windows-2019
41+
target: windows-x64
42+
arch: x86_64
43+
py_arch: x64
44+
asset_mime: application/vnd.microsoft.portable-executable
45+
hidden_import: --hidden-import windows-curses --hidden-import cowsay
46+
extra_pkg: windows-curses cryptography
47+
exe: deploy-freva.exe
48+
49+
steps:
50+
- uses: actions/checkout@v4
51+
- name: Set up Python "3.X" on ${{ matrix.os }}
52+
uses: actions/setup-python@v4
53+
with:
54+
python-version: "3.X"
55+
architecture: ${{ matrix.py_arch }}
56+
- name: Install dependencies
57+
run: |
58+
python3 -m pip install --upgrade pip
59+
python3 -m pip install pyinstaller ansible ${{ matrix.extra_pkg }} .
60+
- name: Build with cmd pyinstaller for ${{ matrix.target }}
61+
run: >
62+
pyinstaller pyinstaller/pyinstaller-deploy-freva.py -c
63+
--name deploy-freva --onefile --clean -i docs/_static/freva_owl.ico
64+
--add-data 'assets/share/freva/deployment:freva_deployment/assets'
65+
--add-data 'src/freva_deployment/versions.json:freva_deployment'
66+
--target-arch ${{matrix.arch}}
67+
${{matrix.hidden_import}}
68+
--exclude-module pycrypto --exclude-module PyInstaller
69+
- name: Test built bindary
70+
run: ./dist/${{matrix.exe}} --help
71+
- name: Upload cmd Asset
72+
uses: actions/upload-artifact@v3
73+
with:
74+
path: dist/${{matrix.exe}}
75+
name: deploy-freva-${{ matrix.target }}
76+
retention-days: 7
77+
78+
build-linux:
79+
name: Build packages
80+
runs-on: ubuntu-latest
81+
strategy:
82+
matrix:
83+
include:
84+
- arch: linux/amd64
85+
target: linux-x64
86+
- arch: linux/arm64
87+
target: linux-arm64
88+
- arch: linux/arm/v7
89+
target: linux-armvl7
90+
- arch: linux/arm/v6
91+
target: linux-armvl6
92+
- arch: linux/ppc64le
93+
target: linux-ppc64
94+
- arch: linux/s390x
95+
target: linux-s390x
96+
- arch: linux/i386
97+
target: linux-i386
98+
99+
steps:
100+
101+
- name: Checkout repository
102+
uses: actions/checkout@v4
103+
with:
104+
fetch-depth: 0
105+
106+
- name: Set up QEMU
107+
uses: docker/setup-qemu-action@v2
108+
with:
109+
platforms: all
110+
111+
- name: Set up Docker Buildx
112+
uses: docker/setup-buildx-action@v2
113+
with:
114+
install: true
115+
116+
- name: Create Buildx builder
117+
run: docker buildx create --use --name mybuilder --driver docker-container
118+
119+
- name: Inspect Buildx builder
120+
run: docker buildx inspect --bootstrap
121+
122+
- name: Build Docker image
123+
uses: docker/build-push-action@v4
124+
with:
125+
file: Dockerfile
126+
platforms: ${{ matrix.arch }}
127+
push: false
128+
load: true
129+
tags: pyinstaller:${{ matrix.target }}
130+
131+
- name: Run PyInstaller in Docker
132+
run: >
133+
docker run --rm -v $PWD:/src -w /src --platform ${{ matrix.arch }}
134+
pyinstaller:${{ matrix.target }} pyinstaller
135+
pyinstaller/pyinstaller-deploy-freva.py -c
136+
--name deploy-freva --onefile --clean -i docs/_static/freva_owl.ico
137+
--add-data 'assets/share/freva/deployment:freva_deployment/assets'
138+
--add-data 'src/freva_deployment/versions.json:freva_deployment'
139+
--hidden-import cowsay --hidden-import cryptography
140+
--exclude-module pycrypto --exclude-module PyInstaller
141+
142+
- name: Test built bindary
143+
run: >
144+
docker run --rm -v $PWD:/src -w /src --platform ${{ matrix.arch }}
145+
pyinstaller:${{ matrix.target }} /src/dist/deploy-freva --help
146+
147+
- name: Upload cmd Asset
148+
if: startsWith(github.ref, 'refs/tags/')
149+
uses: actions/upload-artifact@v4
150+
with:
151+
path: dist/
152+
name: deploy-freva-${{ matrix.target }}
153+
18154
pypi:
19155
name: Create Pip package
20156
permissions:
21157
id-token: write
22-
needs: [tests]
158+
needs: [tests, build-linux, build-no-linux]
23159
runs-on: ubuntu-latest
160+
if: startsWith(github.ref, 'refs/tags/')
24161
steps:
25162
-
26163
name: Checkout
@@ -45,10 +182,12 @@ jobs:
45182
password: ${{ secrets.PYPI_API_TOKEN }}
46183
skip-existing: true
47184
verbose: true
48-
createrelease:
185+
186+
release:
49187
name: Create Release
50-
runs-on: [ubuntu-latest]
51-
needs: pypi
188+
needs: [build-no-linux, build-linux]
189+
runs-on: ubuntu-latest
190+
if: startsWith(github.ref, 'refs/tags/')
52191
steps:
53192
- name: Create Release
54193
id: create_release
@@ -67,53 +206,50 @@ jobs:
67206
with:
68207
name: release_url
69208
path: release_url.txt
70-
build:
71-
name: Build packages
72-
needs: [pypi, createrelease]
73-
runs-on: ${{ matrix.os }}
209+
210+
upload-builds:
211+
name: Add binaries to Release
212+
needs: release
213+
runs-on: ubuntu-latest
74214
strategy:
75215
matrix:
76216
include:
77-
- os: macos-latest
78-
TARGET: macos
79-
CMD_BUILD: >
80-
pyinstaller pyinstaller/pyinstaller-script.py -c --name deploy-freva --onefile
81-
OUT_FILE_NAME: deploy-freva
82-
ASSET_MIME: application/octet-stream
83-
- os: windows-latest
84-
TARGET: windows
85-
CMD_BUILD: pyinstaller pyinstaller/pyinstaller-script.py -c --name deploy-freva --onefile
86-
OUT_FILE_NAME: deploy-freva.exe
87-
ASSET_MIME: application/vnd.microsoft.portable-executable
217+
- target: linux-x64
218+
asset_mime: application/octet-stream
219+
- target: linux-arm64
220+
asset_mime: application/octet-stream
221+
- target: linux-armvl7
222+
asset_mime: application/octet-stream
223+
- target: linux-armvl6
224+
asset_mime: application/octet-stream
225+
- target: linux-ppc64
226+
asset_mime: application/octet-stream
227+
- target: linux-s390x
228+
asset_mime: application/octet-stream
229+
- target: linux-i386
230+
asset_mime: application/octet-stream
231+
- target: osx-x64
232+
asset_mime: application/octet-stream
233+
- target: osx-arm64
234+
asset_mime: application/octet-stream
235+
- target: windows-x64
236+
asset_mime: application/vnd.microsoft.portable-executable
237+
if: startsWith(github.ref, 'refs/tags/')
88238
steps:
89-
- uses: actions/checkout@v4
90-
- name: Set up Python 3.X
91-
uses: actions/setup-python@v4
92-
with:
93-
python-version: "3.X"
94-
- name: Install dependencies
95-
run: |
96-
python3 -m pip install --upgrade pip
97-
python3 -m pip install pyinstaller ansible .
98-
- name: Build with pyinstaller for ${{matrix.TARGET}}
99-
run: ${{matrix.CMD_BUILD}}
100-
- name: Load Release URL File from release job
101-
uses: actions/download-artifact@v1
239+
- name: Checkout repository
240+
uses: actions/checkout@v4
241+
242+
- name: Download artifacts
243+
uses: actions/download-artifact@v3
102244
with:
103-
name: release_url
104-
- name: Get Release File Name & Upload URL
105-
id: get_release_info
106-
shell: bash
107-
run: |
108-
value=`cat release_url/release_url.txt`
109-
echo ::set-output name=upload_url::$value
110-
- name: Upload Release Asset
111-
id: upload-release-asset
245+
path: ./artifacts
246+
247+
- name: Upload Release Assets
112248
uses: actions/upload-release-asset@v1
113249
env:
114250
GITHUB_TOKEN: ${{ secrets.ASSET_TOKEN }}
115251
with:
116-
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
117-
asset_path: ./dist/${{ matrix.OUT_FILE_NAME}}
118-
asset_name: ${{ matrix.OUT_FILE_NAME}}
119-
asset_content_type: ${{ matrix.ASSET_MIME}}
252+
upload_url: ${{ steps.create_release.outputs.upload_url }}
253+
asset_path: ./artifacts/deploy-freva-${{matrix.target}}
254+
asset_name: deploy-freva-${{ matrix.target }}
255+
asset_content_type: ${{matrix.asset_mime}}

Dockerfile

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
from docker.io/alpine
1+
FROM debian:bullseye
22
ARG VERSION
33
LABEL org.opencontainers.image.authors="DRKZ-CLINT"
44
LABEL org.opencontainers.image.source="https://github.com/FREVA-CLINT/freva-deployment.git"
55
LABEL org.opencontainers.image.version="$VERSION"
6-
RUN set -ex &&\
7-
apk add --no-cache python3 py3-pip openssh-client sshpass &&\
8-
apk add --no-cache --virtual /root/build-deps build-base python3-dev \
9-
libffi-dev openssl-dev rust cargo &&\
6+
RUN apt-get update && apt-get install -y build-essential python3-cryptography \
7+
python3-dev python3-pip openssh-client sshpass
8+
RUN apt-get install -y binutils libghc-zlib-dev musl-dev \
9+
librust-libc-dev libc-devtools libffi-dev gcc g++
10+
RUN apt-get install -y python3-appdirs python3-mysqldb python3-yaml \
11+
python3-toml python3-tomlkit python3-requests ansible && \
1012
mkdir -p /opt/freva-deployment &&\
11-
ln -sf python3 /usr/bin/python && \
12-
mkdir -p /tmp/deployment
13+
mkdir -p /tmp/deployment && rm -rf /var/lib/apt/lists/* && \
14+
mkdir -p /src
1315
WORKDIR /tmp/deployment
1416
COPY . .
15-
RUN set -ex &&\
16-
python3 src/freva_deployment/__init__.py &&\
17-
python3 -m pip install --break-system-packages . &&\
18-
rm -rf /root/.cache/pip &&\
19-
rm -rf /var/cache/apk/* &&\
20-
apk del /root/build-deps &&\
21-
rm -rf /root/build-deps &&\
17+
# Install Python dependencies
18+
RUN python3 -m pip install --upgrade pip && \
19+
python3 -m pip install pyinstaller ansible cryptography &&\
20+
python3 src/freva_deployment/__init__.py && \
21+
python3 -m pip install --break-system-packages . && \
22+
rm -rf /root/.cache/pip && \
23+
rm -rf /root/build-deps && \
2224
rm -rf /tmp/deployment
2325
WORKDIR /opt/freva-deployment
2426
VOLUME /opt/freva-deployment
27+
VOLUME /src
2528
CMD ["/usr/bin/deploy-freva"]

0 commit comments

Comments
 (0)