Skip to content

Commit

Permalink
feat: draft arm64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
alubbock committed Oct 15, 2023
1 parent 9bd4aec commit 8293ee8
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 46 deletions.
24 changes: 7 additions & 17 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,8 @@ jobs:
- name: Upload coverage
if: ${{ matrix.dev == '--dev' }}
run: codecov
- name: Export Docker image
if: ${{ matrix.dev == '' && github.event_name == 'push' }}
run: docker save alubbock/thunorweb:dev | gzip > thunorweb-image.tar.gz
- name: Store build image as artifact for deploy stage
if: ${{ matrix.dev == '' && github.event_name == 'push' }}
uses: actions/upload-artifact@v2
with:
name: thunor-web-container
path: thunorweb-image.tar.gz
retention-days: 1
deploy:
needs: build
# needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
Expand All @@ -61,12 +51,10 @@ jobs:
echo "::set-output name=qs_branch::main"
echo "::set-output name=version::${GITHUB_REF/refs\/tags\//}"
fi
- name: Download build image artifact
uses: actions/download-artifact@v2
with:
name: thunor-web-container
- name: Load build image into Docker
run: docker load < thunorweb-image.tar.gz
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout Thunor Web
uses: actions/checkout@v2
- name: Checkout Quickstart Repo
Expand All @@ -76,6 +64,8 @@ jobs:
ref: ${{ steps.release_mode.outputs.qs_branch }}
token: ${{ secrets.API_TOKEN_GITHUB }}
path: thunor-web-quickstart
- name: Build containers
run: python thunorbld.py --use-buildx build
- name: Update and push quickstart repo
run: |
set -e
Expand Down
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
FROM python:3.11-slim-bullseye AS thunorweb_base
MAINTAINER Alex Lubbock <[email protected]>
ENV PYTHONUNBUFFERED 1
ENV THUNOR_HOME=/thunor

RUN apt update && apt install -y libpq-dev gcc libmagic1 \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir $THUNOR_HOME
WORKDIR $THUNOR_HOME

ADD requirements.txt $THUNOR_HOME
ADD thunor $THUNOR_HOME/thunor
RUN pip3 install --no-cache-dir -r requirements.txt
RUN dpkg --purge gcc
CMD ["uwsgi", "--master", "--socket", ":8000", "--module", "thunordjango.wsgi", "--uid", "www-data", "--gid", "www-data", "--enable-threads"]
ADD manage.py $THUNOR_HOME
ADD thunordjango $THUNOR_HOME/thunordjango
RUN cd $THUNOR_HOME/thunor && python3 setup.py install
ADD thunorweb $THUNOR_HOME/thunorweb
ARG THUNORWEB_VERSION=unknown
RUN printf "def get_versions():\n return {'version': '$THUNORWEB_VERSION'}\n" > $THUNOR_HOME/thunorweb/_version.py

FROM thunorweb_base

COPY _state/deploy-test/_state/thunor-static-build $THUNOR_HOME/_state/thunor-static
22 changes: 0 additions & 22 deletions Dockerfile.base

This file was deleted.

43 changes: 36 additions & 7 deletions thunorbld.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,33 @@ def generate_static(self):
self._log.info('Generate static files')
return self._run_cmd(cmd)

# def _init_buildx(self):
# self._log.info("Init docker buildx")
# return self._run_cmd([
# 'docker', 'buildx', 'create', '--name', 'thunorbuild', '--use', '--append'
# ])

# def _deinit_buildx(self):
# self._log.info("Deinit docker buildx")
# return self._run_cmd([
# 'docker', 'buildx', 'rm', 'thunorbuild'
# ])

def _build_base_image(self):
self._log.info('Build thunorweb_base image')
return self._run_cmd(['docker', 'build', '-t', 'thunorweb_base',
base_cmd = ['docker']
if self.args.use_buildx:
base_cmd += ['buildx', 'build', '--platform=linux/amd64,linux/arm64']
else:
base_cmd += ['build']
return self._run_cmd(base_cmd +
['-t',
'thunorweb_base',
'--target',
'thunorweb_base',
'--build-arg',
'THUNORWEB_VERSION={}'.format(
thunorweb_version),
'-f',
os.path.join(self.cwd, 'Dockerfile.base'),
self.cwd])

def collect_static(self):
Expand Down Expand Up @@ -95,8 +114,13 @@ def thunorweb_build(self):

self.make_static()
self._log.info('Build main container')
self._run_cmd(['docker',
'build',
base_cmd = ['docker']
if self.args.use_buildx:
base_cmd += ['buildx', 'build', '--platform=linux/amd64,linux/arm64']
else:
base_cmd += ['build']
self._run_cmd(base_cmd +
['--platform=linux/amd64,linux/arm64',
'-t', 'alubbock/thunorweb:dev',
self.cwd])
if 'cleanup' in self.args and self.args.cleanup:
Expand Down Expand Up @@ -208,6 +232,8 @@ def _parser(self):
parser.add_argument('--dry-run', action='store_true', default=False,
help='Dry run (don\'t execute any commands, '
'just show them)')
parser.add_argument('--use-buildx', action='store_true', default=False,
help='Use docker buildx for cross-platform builds')

subparsers = parser.add_subparsers()

Expand Down Expand Up @@ -266,5 +292,8 @@ def _parser(self):
parser = thunorbld._parser()
parser_args = parser.parse_args()
thunorbld._set_args(parser_args)
if hasattr(parser_args, 'func'):
parser_args.func()
try:
if hasattr(parser_args, 'func'):
parser_args.func()
finally:
pass

0 comments on commit 8293ee8

Please sign in to comment.