Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]: Add Dockerfile #75

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f9ce232
:rocket: Add configured Dockerfile
arjxn-py Apr 5, 2024
a589fe6
:writing_hand: Propose some changes in `install_go.sh` script to make…
arjxn-py Apr 5, 2024
d99a35c
:nail_care: Add `install_zig.sh` script to install zig
arjxn-py Apr 5, 2024
2c50a0d
:pushpin: Modify Preliminary Dockerfile
arjxn-py Apr 19, 2024
0645456
↩️ Revert changes in `install_go.sh` & remove `install_zig.sh`
arjxn-py Apr 19, 2024
97a7eb4
📛 Merge to upstream & resolve conflicts
arjxn-py Apr 19, 2024
a2bcfe5
🪩 Automated fixes from https://pre-commit.ci
pre-commit-ci[bot] Apr 19, 2024
341dee5
:heavy_plus_sign: Install `g++` required for `libsaas`
arjxn-py Apr 19, 2024
76b2cb5
:memo: Update Dockerfile to set `GO_VERSION` and `ZIG_VERSION` enviro…
arjxn-py Apr 22, 2024
752013e
:airplane: Get rid of venv
arjxn-py Apr 22, 2024
7ecd2be
:paperclip: Merge to upstream
arjxn-py Apr 22, 2024
494673d
:whale: Add workflow to build & push docker image
arjxn-py Apr 22, 2024
43ae034
Merge branch 'main' into add-dockerfile
arjxn-py May 31, 2024
f8c4e6c
Merge branch 'main' into add-dockerfile
arjxn-py Jun 2, 2024
8a3f01c
:twisted_rightwards_arrows: Two separate Dockerfiles
arjxn-py Jun 2, 2024
227652f
:heavy_plus_sign: Consolidate two Dockerfiles into one using build-ti…
arjxn-py Jun 7, 2024
d33a667
:writing_hand: Change BUILDING_FOR_WINDOWS -> BUILD_STATIC
arjxn-py Jun 7, 2024
f82aa83
🪩 Automated fixes from https://pre-commit.ci
pre-commit-ci[bot] Jun 7, 2024
33bb909
:checkered_flag: Check for `linux-musl` in `CC` & `CXX` environment v…
arjxn-py Jun 9, 2024
0478067
:mag: Check for windows as well in `BUILD_STATIC`
arjxn-py Jul 1, 2024
d703210
:heavy_plus_sign: Merge to upstream
arjxn-py Jul 1, 2024
4e39c50
:test_tube: Run tests inside the built Docker image
arjxn-py Jul 1, 2024
b39c4b0
Merge branch 'main' into add-dockerfile
agriyakhetarpal Jul 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build and push Docker images to Docker Hub

on:
workflow_dispatch:
push:
branches:
- main

jobs:
build_docker_image:
# This workflow is only of value to Owner and would always be skipped in forks
if: github.repository_owner == 'agriyakhetarpal'
name: Build image
runs-on: buildjet-2vcpu-ubuntu-2204-arm

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image to Docker Hub
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
tags: agriyakhetarpal/hugo:latest # To be updated with exact Docker Hub username and image name
push: false
platforms: linux/amd64, linux/arm64

- name: Run tests inside the built Docker image
run: |
docker run --rm agriyakhetarpal/hugo:latest hugo version
docker run --rm agriyakhetarpal/hugo:latest hugo env

- name: List built image(s)
run: docker images
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM python:3.11.9-slim

ENV ZIG_VERSION=0.11.0

WORKDIR /

RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
g++ \
clang \
git \
wget \
dos2unix \
xz-utils \
musl-tools \
&& rm -rf /var/lib/apt/lists/*

ARG TARGETARCH=x86_64

RUN if [ "$TARGETARCH" = "arm64" ]; then \
wget "https://ziglang.org/builds/zig-linux-aarch64-${ZIG_VERSION}.tar.xz" && \
tar -C /usr/local -xf "zig-linux-aarch64-${ZIG_VERSION}.tar.xz" && \
rm "zig-linux-aarch64-${ZIG_VERSION}.tar.xz"; \
else \
wget "https://ziglang.org/builds/zig-linux-x86_64-${ZIG_VERSION}.tar.xz" && \
tar -C /usr/local -xf "zig-linux-x86_64-${ZIG_VERSION}.tar.xz" && \
rm "zig-linux-x86_64-${ZIG_VERSION}.tar.xz"; \
fi

ENV PATH="${PATH}:/usr/local/zig-linux-${TARGETARCH}-${ZIG_VERSION}"

RUN git clone https://github.com/agriyakhetarpal/hugo-python-distributions && \
cd hugo-python-distributions && \
pip install -e . && \
pip install .

WORKDIR /hugo-python-distributions

CMD ["/bin/bash"]
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,13 @@ def run(self):

# Build a static binary on Windows to avoid missing DLLs from MinGW,
# i.e., libgcc_s_seh-1.dll, libstdc++-6.dll, etc.
BUILDING_FOR_WINDOWS = (
os.environ.get("GOOS") == "windows" or sys.platform == "win32"
BUILD_STATIC = (
os.environ.get("GOOS") == "windows"
or sys.platform == "win32"
or "linux-musl" in os.environ.get("CC", "")
or "linux-musl" in os.environ.get("CXX", "")
)

if BUILDING_FOR_WINDOWS:
if BUILD_STATIC:
ldflags.append("-extldflags '-static'")

if not (Path(HUGO_CACHE_DIR).resolve() / f"hugo-{HUGO_VERSION}").exists():
Expand Down
Loading