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

Fix locales within container #36

Merged
merged 4 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Docker ignore for amphora image builders
# This doesn't use docker
k8s-image-builder/

# Don't include any built images if there are any
**/*.raw
**/*.qcow*
13 changes: 0 additions & 13 deletions .github/workflows/amphora_builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,9 @@ jobs:
with:
scandir: "./amphora-image-builder"

docker-build:
name: Test Docker Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker Image
uses: docker/build-push-action@v6
with:
context: ./amphora-image-builder
push: false
tags: "amphora-builder"

amphora-e2e:
name: Amphora E2E
runs-on: ubuntu-latest
needs: ["docker-build"]
steps:
- uses: actions/checkout@v4
- name: Exec Amphora build
Expand Down
7 changes: 6 additions & 1 deletion amphora-image-builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ RUN apt-get update && \
qemu-utils git kpartx debootstrap curl && \
apt-get clean all

COPY entrypoint.sh /entrypoint.sh
# Copy this entire git directory, as we may be on a branch with changes we want to include
# rather than main
COPY ./ /opt/cloud-image-builders


COPY amphora-image-builder/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT [ "bash", "/entrypoint.sh" ]
8 changes: 6 additions & 2 deletions amphora-image-builder/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/bin/bash

set -e
set -euo pipefail

docker build . -t amphora-image-builder:local
# Move up a dir so we can include this git repo in the build
# so any changes to the elements can be tested
cd ..
docker build -f amphora-image-builder/Dockerfile -t amphora-image-builder:local .

# The Amphora builder requires privileged access to the host
# to mount /proc and /sys
docker run --privileged -v "$(pwd)":/output amphora-image-builder:local
cd amphora-image-builder
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
set -euo pipefail

#install ansible
apt-get update
apt-get install python3-pip python3-venv -y
/usr/bin/python3 -m venv /tmp/amphora-venv
source /tmp/amphora-venv/bin/activate
/usr/bin/python3 -m pip install ansible
/usr/bin/git clone https://github.com/stfc/cloud-image-builders.git
cd cloud-image-builders

apt-get install language-pack-en -y
locale-gen en_GB.UTF-8
dpkg-reconfigure locales
dpkg-reconfigure --frontend noninteractive locales
update-locale LC_ALL=en_GB.UTF-8 LANG=en_GB.UTF-8
source /etc/default/locale
locale
Expand All @@ -20,5 +23,6 @@ apt-get install gpg-agent -y

hostname
sed -i "s/hosts: default/hosts: localhost/g" os_builders/*.yml
mkdir -p /var/ossec/etc/extra
echo "{\"groups\": [\"default\", \"cloud\", \"ubuntu\", \"debian\", \"octavia-amphora\"], \"labels\": {\"amphora-build-date\": \"$(date '+%Y-%m-%d %H:%M:%S')\" }}" > /var/ossec/etc/extra/03-amphora.json
ansible-playbook os_builders/prepare_user_image.yml --extra-vars provision_this_machine=true -i os_builders/inventory/localhost.yml
7 changes: 4 additions & 3 deletions amphora-image-builder/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ DIB_REPO_PATH="$(pwd)/octavia"
export DIB_REPO_PATH

# run local config elements
git clone https://github.com/stfc/cloud-image-builders.git
cd /tmp/cloud-image-builders
cd /opt/cloud-image-builders
chmod 755 amphora-image-builder/elements/vm_baseline/*/*

cd /tmp
DIB_LOCAL_ELEMENTS="vm_baseline"
export DIB_LOCAL_ELEMENTS
DIB_LOCAL_ELEMENTS_PATH="/tmp/cloud-image-builders/amphora-image-builder/elements"

DIB_LOCAL_ELEMENTS_PATH="/opt/cloud-image-builders/amphora-image-builder/elements"
export DIB_LOCAL_ELEMENTS_PATH

cd octavia/diskimage-create
Expand Down