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

Update image, add Github workflow, add tinycore 12.0 #16

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: tatsushid
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Set update schedule for GitHub Actions

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"
37 changes: 37 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: docker-tinycore

on:
push:
branches:
- 'main'
- 'master'
- 'dev'
paths-ignore:
- '**/README.md'
pull_request:
branches:
- '*'
schedule:
- cron: "0 0 * */1 *" # At 00:00 in every month.
workflow_dispatch:

jobs:
image:
name: docker-tinycore
runs-on: ubuntu-20.04
steps:
- name: "📥 Checkout Code"
uses: actions/checkout@v2.3.4
with:
submodules: 'recursive'
fetch-depth: 0
- name: "🛠️ Build"
run: make all
# - name: "Logging to docker"
# run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }}
# - name: "📤 Upload to hub.docker.com"
# run: docker push tinycore --all-tags
- name: "🧹 Clean"
run: make clean


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.tar.gz
Binary file removed 10.0/x86/rootfs.tar.gz
Binary file not shown.
Binary file removed 10.0/x86/squashfs-tools.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions 10.0/x86/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine
FROM alpine:latest

ADD tce-load.patch /tmp/
RUN apk add --no-cache curl \
RUN apk add --no-cache curl patch \
&& curl -SLO http://www.tinycorelinux.net/10.x/x86/archive/10.0/distribution_files/rootfs.gz \
&& mkdir rootfs \
&& cd rootfs \
Expand Down
Binary file removed 10.0/x86_64/rootfs64.tar.gz
Binary file not shown.
Binary file removed 10.0/x86_64/squashfs-tools.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions 10.0/x86_64/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine
FROM alpine:latest

ADD tce-load.patch /tmp/
RUN apk add --no-cache curl \
RUN apk add --no-cache curl patch \
&& curl -SLO http://www.tinycorelinux.net/10.x/x86_64/archive/10.0/distribution_files/rootfs64.gz \
&& mkdir rootfs64 \
&& cd rootfs64 \
Expand Down
Binary file removed 10.1/x86/rootfs.tar.gz
Binary file not shown.
Binary file removed 10.1/x86/squashfs-tools.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions 10.1/x86/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine
FROM alpine:latest

ADD tce-load.patch /tmp/
RUN apk add --no-cache curl \
RUN apk add --no-cache curl patch \
&& curl -SLO http://www.tinycorelinux.net/10.x/x86/release/distribution_files/rootfs.gz \
&& mkdir rootfs \
&& cd rootfs \
Expand Down
Binary file removed 10.1/x86_64/rootfs64.tar.gz
Binary file not shown.
Binary file removed 10.1/x86_64/squashfs-tools.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions 10.1/x86_64/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine
FROM alpine:latest

ADD tce-load.patch /tmp/
RUN apk add --no-cache curl \
RUN apk add --no-cache curl patch \
&& curl -SLO http://www.tinycorelinux.net/10.x/x86_64/release/distribution_files/rootfs64.gz \
&& mkdir rootfs64 \
&& cd rootfs64 \
Expand Down
Binary file removed 11.0/x86/rootfs.tar.gz
Binary file not shown.
Binary file removed 11.0/x86/squashfs-tools.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions 11.0/x86/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine
FROM alpine:latest

ADD tce-load.patch /tmp/
RUN apk add --no-cache curl \
RUN apk add --no-cache curl patch \
&& curl -SLO http://www.tinycorelinux.net/11.x/x86/release/distribution_files/rootfs.gz \
&& mkdir rootfs \
&& cd rootfs \
Expand Down
Binary file removed 11.0/x86_64/rootfs64.tar.gz
Binary file not shown.
Binary file removed 11.0/x86_64/squashfs-tools.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions 11.0/x86_64/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine
FROM alpine:latest

ADD tce-load.patch /tmp/
RUN apk add --no-cache curl \
RUN apk add --no-cache curl patch \
&& curl -SLO http://www.tinycorelinux.net/11.x/x86_64/release/distribution_files/rootfs64.gz \
&& mkdir rootfs64 \
&& cd rootfs64 \
Expand Down
10 changes: 10 additions & 0 deletions 12.0/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SUBDIRS := x86 x86_64

.PHONY: all clean $(SUBDIRS)

all: $(SUBDIRS)

clean: $(SUBDIRS)

$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)
15 changes: 15 additions & 0 deletions 12.0/x86/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM scratch
ADD rootfs.tar.gz /
ADD squashfs-tools.tar.gz /

RUN mkdir -p /tmp/tce/optional \
&& chown -R root:staff /tmp/tce /usr/local/tce.installed \
&& chmod -R g+w /tmp/tce \
&& $(cd etc/sysconfig; ln -s ../../tmp/tce tcedir) \
&& echo -n tc > etc/sysconfig/tcuser \
&& . /etc/init.d/tc-functions \
&& ldconfig \
&& setupHome

USER tc
CMD ["/bin/sh"]
21 changes: 21 additions & 0 deletions 12.0/x86/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 Tatsushi Demachi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
34 changes: 34 additions & 0 deletions 12.0/x86/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
IMAGE_NAME := tinycore
IMAGE_TAG := 12.0-x86
TMP_IMAGE_NAME := $(IMAGE_NAME)-tar-builder
TMP_CONTAINER_NAME := $(IMAGE_NAME)-tar-exporter

.PHONY: all build stop clean

all: build

build: rootfs.tar.gz
docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .
docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_NAME):latest

rootfs.tar.gz: squashfs-tools.tar.gz
docker build -t $(TMP_IMAGE_NAME) src
docker run --name $(TMP_CONTAINER_NAME) $(TMP_IMAGE_NAME)
docker wait $(TMP_CONTAINER_NAME)
docker cp $(TMP_CONTAINER_NAME):/tmp/rootfs.tar.gz ./
docker rm $(TMP_CONTAINER_NAME)
docker rmi $(TMP_IMAGE_NAME)

squashfs-tools.tar.gz:
docker run -d --privileged --name $(TMP_CONTAINER_NAME) alpine sleep 180
docker start $(TMP_CONTAINER_NAME)
docker exec -i $(TMP_CONTAINER_NAME) /bin/sh -c 'cat > /tmp/build_squashfs_tools.sh; /bin/sh /tmp/build_squashfs_tools.sh' < src/build_squashfs_tools.sh > squashfs-tools.tar.gz
docker kill $(TMP_CONTAINER_NAME)
docker rm $(TMP_CONTAINER_NAME)

clean:
docker ps | grep -q $(TMP_CONTAINER_NAME) && docker stop $(TMP_CONTAINER_NAME) || true
docker ps -a | grep -q $(TMP_CONTAINER_NAME) && docker rm $(TMP_CONTAINER_NAME) || true
docker images $(IMAGE_NAME) | grep -q $(IMAGE_TAG) && docker rmi $(IMAGE_NAME):$(IMAGE_TAG) || true
docker images $(IMAGE_NAME) | grep -q latest && docker rmi $(IMAGE_NAME):latest || true
docker images | grep -q $(TMP_IMAGE_NAME) && docker rmi $(TMP_IMAGE_NAME) || true
32 changes: 32 additions & 0 deletions 12.0/x86/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Tiny Core Linux x86 Docker Image Builder
========================================

Dockerfile and helper scripts for building a very small CLI system image based
on Tiny Core Linux developed at [The Core Project](http://tinycorelinux.net).
It builds Core 11.0 x86 image by using following packages which were
converted those archive type from The Core Project packages.

- rootfs.tar.gz: contains base system binaries and a file system layout
- squashfs-tools.tar.gz: contains a squashfs builder and expander

Those original packages are found under http://tinycorelinux.net/11.x/x86

## How to build the image

Just run

```bash
make
```

To clean up the directory, run

```bash
make clean
```

## License

rootfs.tar.gz, squashfs-tools.tar.gz and tce-load.patch are under
[GPLv2](http://www.gnu.org/licenses/gpl-2.0.html). The other build scripts are
under [MIT](LICENSE).
18 changes: 18 additions & 0 deletions 12.0/x86/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM alpine:latest

ADD tce-load.patch /tmp/
RUN apk add --no-cache curl patch \
&& curl -SLO http://www.tinycorelinux.net/12.x/x86/release/distribution_files/rootfs.gz \
&& mkdir rootfs \
&& cd rootfs \
&& gzip -dc ../rootfs.gz | cpio -id \
&& rm -f ../rootfs.gz \
&& cd usr/bin \
&& patch < /tmp/tce-load.patch \
&& cd ../.. \
&& rm -f /tmp/tce-load.patch \
&& tar cf - . | gzip -c > /tmp/rootfs.tar.gz \
&& cd .. \
&& rm -rf rootfs

CMD ["/bin/true"]
39 changes: 39 additions & 0 deletions 12.0/x86/src/build_squashfs_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh
URL_TCZ=http://tinycorelinux.net/12.x/x86/tcz

apk add --no-cache curl squashfs-tools >/dev/null

download_tcz() {
# Ignore empty/whitespace only
[ -z "$(echo $1)" ] && return
[ -f "$1" ] && return
curl -SLO $URL_TCZ/$1 >/dev/null
# Attempt to download .dep, but it might not exist
curl --fail -LO $URL_TCZ/$1.dep >/dev/null 2>&1
# Make sure the .dep has an empty last line
[ -f "$1.dep" ] && echo >> "$1.dep"
}

# Download squashfs-tools.tcz
download_tcz squashfs-tools.tcz

# Download any found dependencies, repeat 4 times for "recursion"
if [ -f squashfs-tools.tcz.dep ]; then
COUNTDOWN=5
while [ "$COUNTDOWN" -gt 0 ]; do
COUNTDOWN=$(($COUNTDOWN - 1))
for t in $(cat *.dep|sort|uniq); do
download_tcz $t
done
done
fi

[ -d /mnt ] || mkdir /mnt

# Extract all of the downloaded tcz files
for t in $(find -name '*.tcz'); do
unsquashfs -f -d /mnt $t >/dev/null
done

# Make a tarball of all of it and print to stdout
tar cf - -C /mnt . | gzip -c
39 changes: 39 additions & 0 deletions 12.0/x86/src/tce-load.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--- tce-load.orig 2020-03-01 03:44:26.000000000 +0000
+++ tce-load 2020-03-01 03:49:22.300332000 +0000
@@ -81,15 +81,15 @@

copyInstall() {
[ -d /mnt/test ] || sudo /bin/mkdir -p /mnt/test
- sudo /bin/mount $1 /mnt/test -t squashfs -o loop,ro
+ sudo /usr/local/bin/unsquashfs -f -d /mnt/test $1
if [ "$?" == 0 ]; then
if [ "$(ls -A /mnt/test)" ]; then
yes "$FORCE" | sudo /bin/cp -ai /mnt/test/. / 2>/dev/null
[ -n "`find /mnt/test/ -type d -name modules`" ] && MODULES=TRUE
fi
- sudo /bin/umount -d /mnt/test
+ sudo rm -rf /mnt/test
fi
- [ "$BOOTING" ] || rmdir /mnt/test
+ [ "$BOOTING" ] || [ -d /mnt/test ] && rmdir /mnt/test
}

update_system() {
@@ -269,7 +269,7 @@
F="${F##*/}"
app_exists "$F" "." || fetch_app "$F"
[ -f "$TCEINSTALLED/${F%.*}" ] || install "$F"
- done || exit 1 # subshell cannot exit directly
+ done || exit 0 # subshell cannot exit directly
fi

if [ "$TARGETSLOCAL" ]; then
@@ -286,7 +286,7 @@
abort_to_saved_dir
fi
fi
- done || exit 1 # subshell cannot exit directly
+ done || exit 0 # subshell cannot exit directly
fi

[ "$BOOTING" ] && exit 0
15 changes: 15 additions & 0 deletions 12.0/x86_64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM scratch
ADD rootfs64.tar.gz /
ADD squashfs-tools.tar.gz /

RUN mkdir -p /tmp/tce/optional \
&& chown -R root:staff /tmp/tce /usr/local/tce.installed \
&& chmod -R g+w /tmp/tce \
&& $(cd etc/sysconfig; ln -s ../../tmp/tce tcedir) \
&& echo -n tc > etc/sysconfig/tcuser \
&& . /etc/init.d/tc-functions \
&& ldconfig \
&& setupHome

USER tc
CMD ["/bin/sh"]
21 changes: 21 additions & 0 deletions 12.0/x86_64/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 Tatsushi Demachi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 32 additions & 0 deletions 12.0/x86_64/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
IMAGE_NAME := tinycore
IMAGE_TAG := 12.0-x86_64
TMP_IMAGE_NAME := $(IMAGE_NAME)-tar-builder
TMP_CONTAINER_NAME := $(IMAGE_NAME)-tar-exporter

.PHONY: all build stop clean

all: build

build: rootfs64.tar.gz
docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .

rootfs64.tar.gz: squashfs-tools.tar.gz
docker build -t $(TMP_IMAGE_NAME) src
docker run --name $(TMP_CONTAINER_NAME) $(TMP_IMAGE_NAME)
docker wait $(TMP_CONTAINER_NAME)
docker cp $(TMP_CONTAINER_NAME):/tmp/rootfs64.tar.gz ./
docker rm $(TMP_CONTAINER_NAME)
docker rmi $(TMP_IMAGE_NAME)

squashfs-tools.tar.gz:
docker run -d --privileged --name $(TMP_CONTAINER_NAME) alpine sleep 180
docker start $(TMP_CONTAINER_NAME)
docker exec -i $(TMP_CONTAINER_NAME) /bin/sh -c 'cat > /tmp/build_squashfs_tools.sh; /bin/sh /tmp/build_squashfs_tools.sh' < src/build_squashfs_tools.sh > squashfs-tools.tar.gz
docker kill $(TMP_CONTAINER_NAME)
docker rm $(TMP_CONTAINER_NAME)

clean:
docker ps | grep -q $(TMP_CONTAINER_NAME) && docker stop $(TMP_CONTAINER_NAME) || true
docker ps -a | grep -q $(TMP_CONTAINER_NAME) && docker rm $(TMP_CONTAINER_NAME) || true
docker images $(IMAGE_NAME) | grep -q $(IMAGE_TAG) && docker rmi $(IMAGE_NAME):$(IMAGE_TAG) || true
docker images | grep -q $(TMP_IMAGE_NAME) && docker rmi $(TMP_IMAGE_NAME) || true
Loading