Skip to content

Commit

Permalink
feat: it now works
Browse files Browse the repository at this point in the history
  • Loading branch information
yyewolf committed Aug 23, 2023
1 parent 246cfde commit a38b7a4
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 87 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ go.work

borne/OVMF.fd
>>>>>>> feat: new efi builder

borne/build/

borne/fs/rootfs.tar.gz
9 changes: 6 additions & 3 deletions borne/.bashrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/sh
# .bashrc

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

# StartX and start chromium in full screen kiosk mode
if [ -z "$DISPLAY" ] && [ $(tty) = /dev/tty1 ]; then
startx
fi
# if [ -z "$DISPLAY" ] && [ $(tty) = /dev/tty1 ]; then
# startx
# fi

3 changes: 2 additions & 1 deletion borne/.xinitrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ xset s off
xset s noblank

unclutter &
chromium-browser /path/to/your/file.html --window-size=1920,1080 --start-fullscreen --kiosk --incognito --noerrdialogs --disable-translate --no-first-run --fast --fast-start --disable-infobars --disable-features=TranslateUI --disk-cache-dir=/dev/null --password-store=basic
firefox
# chromium-browser /path/to/your/file.html --window-size=1920,1080 --start-fullscreen --kiosk --incognito --noerrdialogs --disable-translate --no-first-run --fast --fast-start --disable-infobars --disable-features=TranslateUI --disk-cache-dir=/dev/null --password-store=basic
84 changes: 8 additions & 76 deletions borne/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,95 +3,27 @@ LABEL project=bar-borne

WORKDIR /root

RUN wget -O rootfs.tar.gz https://cdimage.ubuntu.com/ubuntu-base/releases/22.04/release/ubuntu-base-22.04-base-amd64.tar.gz

COPY fs/rootfs.tar.gz .
RUN mkdir rootfs/
RUN tar -C rootfs/ -xf rootfs.tar.gz

COPY ./fs/etc rootfs/etc

RUN fakeroot fakechroot chroot rootfs/ \
apt-get update

RUN chroot rootfs/ \
apt-get install -yq --no-install-recommends \
linux-image-generic initramfs-tools parted overlayroot systemd systemd-sysv dbus sudo

RUN fakeroot fakechroot chroot rootfs/ \
apt-get clean

RUN chroot rootfs/ \
useradd -m ubuntu -G sudo -s /bin/bash
RUN chroot rootfs/ \
bash -c 'echo "ubuntu:ubuntu" | chpasswd'

# Only needed during install to prevent kernel/initrd symlinks from being created
RUN chroot rootfs/ \
rm /etc/kernel-img.conf

# Usefull stuff for our bar purposes :
# Install npm, git, xorg and chromium
# clone https://github.com/yyewolf/bar
# go to bar/frontend
# setup config.json with the right values :
# echo {"api":"http://localhost:8080","apiws":"ws://localhost:8080","local_token": "jesuisleplusfort"} > bar/frontend/static/config.json
# do npm install and setup a service that does node build/index.js at boot in bar/frontend
# made it so x server starts at boot and chromium is in kiosk mode as soon as x server starts
# made it so chromium starts at boot and goes to localhost:8080

COPY bar.service .
COPY override.conf .
COPY .bashrc .
COPY .xinitrc .

RUN cp bar.service rootfs/etc/systemd/system/bar.service
RUN mkdir rootfs/etc/systemd/system/getty@tty1.service.d
RUN cp override.conf rootfs/etc/systemd/system/getty@tty1.service.d/override.conf
RUN cp .bashrc rootfs/home/ubuntu/.bashrc
RUN cp .xinitrc rootfs/home/ubuntu/.xinitrc

RUN chroot rootfs/ \
apt-get install -y --no-install-recommends \
curl git xorg chromium-browser unclutter

# download nvm install script
RUN apt update && apt install curl bzip2 -y
RUN curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh -o install_nvm.sh
RUN mv install_nvm.sh rootfs/home/ubuntu/install_nvm.sh
RUN curl -L -o firefox.tar.bz2 "https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=en-US"
RUN tar xjf firefox.tar.bz2 -C rootfs/usr/lib
RUN chmod +x rootfs/usr/lib/firefox/firefox
RUN ln -s /usr/lib/firefox/firefox /usr/bin/firefox

RUN chroot rootfs/ /bin/bash <<EOF
cd ~/ && \
git clone https://github.com/nvm-sh/nvm.git .nvm && \
cd .nvm && \
. ./nvm.sh && \
cd /home/ubuntu && \
cat install_nvm.sh | /bin/bash && \
nvm install --lts && \
nvm use --lts && \
git clone https://github.com/yyewolf/bar && \
cd bar/frontend && \
npm ci && \
npm run build && \
echo {"api":"http://localhost:8080","apiws":"ws://localhost:8080","local_token": "jesuisleplusfort"} > static/config.json && \
systemctl enable bar.service

RUN echo borne > rootfs/etc/hostname
RUN echo <<EOF >> rootfs/etc/hosts
127.0.1.1 borne
EOF


COPY ./utils/sectors.sh .

# Create empty file for containing the partitions
RUN fallocate -l 4GiB image.img
RUN fallocate -l 6GiB image.img

# Set up partition table
RUN parted -s -- image.img \
mktable gpt \
mkpart primary 0% 100MiB \
mkpart primary 100MiB -16MiB \
mkpart primary -16MiB 100% \
mkpart primary 100MiB -1000MiB \
mkpart primary -1000MiB 100% \
set 1 esp on

RUN mkdir -p esp/EFI/BOOT esp/EFI/ubuntu esp/grub
Expand Down
51 changes: 51 additions & 0 deletions borne/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM ubuntu:latest
LABEL project=bar-borne
COPY ./fs/etc /etc
RUN apt-get update -y
RUN echo "root:root" | chpasswd
RUN apt-get -y install \
linux-image-generic \
systemd-sysv
RUN apt-get install -yq --no-install-recommends \
initramfs-tools parted overlayroot systemd systemd-sysv dbus sudo bash
RUN useradd -m ubuntu -G sudo -s /bin/bash
RUN bash -c 'echo "ubuntu:ubuntu" | chpasswd'
RUN apt-get clean
RUN rm /etc/kernel-img.conf

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y \
curl bzip2 xorg git unclutter \
libdbus-glib-1-2 libpci-dev libglib2.0-0 libstdc++6 libxtst6 \
dbus-x11 network-manager pulseaudio nano
RUN curl -L -o firefox.tar.bz2 "https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=en-US"
RUN tar xjf firefox.tar.bz2 -C /usr/lib
RUN chmod +x /usr/lib/firefox/firefox
RUN ln -s /usr/lib/firefox/firefox /usr/bin/firefox

RUN apt-get install xserver-xorg-core xserver-xorg openbox -y

RUN rm /bin/sh && ln -s /bin/bash /bin/sh

# Run as ubuntu
USER ubuntu
ENV HOME=/home/ubuntu
WORKDIR /home/ubuntu/
RUN git clone https://github.com/yyewolf/bar
WORKDIR /home/ubuntu/bar/frontend
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
&& . /home/ubuntu/.nvm/nvm.sh \
&& nvm install --lts \
&& nvm use --lts \
&& cd /home/ubuntu/bar/frontend \
&& npm ci \
&& npm run build
RUN echo {"api":"http://localhost:8080","apiws":"ws://localhost:8080","local_token": "jesuisleplusfort"} > static/config.json

USER root
RUN mkdir /etc/systemd/system/getty@tty1.service.d
COPY bar.service /etc/systemd/system/bar.service
COPY override.conf /etc/systemd/system/getty@tty1.service.d/override.conf
COPY .bashrc /home/ubuntu/.bashrc
COPY .xinitrc /home/ubuntu/.xinitrc
RUN systemctl enable bar.service
16 changes: 9 additions & 7 deletions borne/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ version: "3"

tasks:
build:
desc: "Build Alpine image"
desc: "Build image"
cmds:
- echo "[Building Alpine image]"
- echo "[Building base system]"
- docker build -f Dockerfile.ubuntu -t bar/borne .
- docker export -o fs/rootfs.tar.gz `docker run -d bar/borne /bin/true`
- echo "[Building image]"
- docker build -o build .
test:
desc: "Test Alpine image"
desc: "Test image"
cmds:
- wget -nc https://github.com/clearlinux/common/raw/master/OVMF.fd
# start with network
- qemu-system-x86_64 -hda build/image.img -smp 4 -m 2G -bios OVMF.fd -nic user,model=virtio-net-pci
- qemu-system-x86_64 -hda build/image.img -smp 4 -m 4G -bios OVMF.fd -nic user,model=virtio-net-pci
clean:
desc: "Clean Alpine image"
desc: "Clean image"
ignore_error: true
cmds:
- echo "[Cleaning Alpine image]"
- echo "[Cleaning image]"
- docker rm `docker ps -qa -f=label=project="bar-borne"`
- docker rmi `docker images -q bar/*`

0 comments on commit a38b7a4

Please sign in to comment.