Skip to content

Commit

Permalink
test: setup insecure registry at localhost:5000
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 committed Mar 11, 2023
1 parent 63465e8 commit dccc7a0
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ jobs:
sudo podman save --format docker-archive --output $ARCHIVE_DIR/docker-archive alpine:latest
sudo podman save --format oci-archive --output $ARCHIVE_DIR/oci-archive alpine:latest
sudo podman image rm alpine:latest
- name: Add localhost as an insecure registry
run: |
cat /etc/containers/registries.conf
sudo bash -c 'cat <<EOF >> /etc/containers/registries.conf
[[registry]]
location = "localhost:5000"
insecure = true
EOF'
- name: Run Tests
run: sudo -E GOPATH=$PWD/build CI=1 env PATH="$PATH" /home/runner/go/bin/gotestsum --junitfile build/test/result.xml -- -timeout=15m . ./api
- name: Archive test result
Expand Down
84 changes: 84 additions & 0 deletions lima.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Example to use Podman instead of containerd & nerdctl
# $ limactl start ./podman-rootful.yaml
# $ limactl shell podman-rootful sudo podman run -it -v $HOME:$HOME --rm docker.io/library/alpine

# To run `podman` on the host (assumes podman-remote is installed):
# $ export CONTAINER_HOST=$(limactl list podman-rootful --format 'unix://{{.Dir}}/sock/podman.sock')
# $ podman --remote ...

# To run `docker` on the host (assumes docker-cli is installed):
# $ export DOCKER_HOST=$(limactl list podman-rootful --format 'unix://{{.Dir}}/sock/podman.sock')
# $ docker ...

# This example requires Lima v0.8.0 or later
arch: "x86_64"
cpus: 8
memory: "16G"
images:
- location: "https://download.fedoraproject.org/pub/fedora/linux/releases/36/Cloud/x86_64/images/Fedora-Cloud-Base-36-1.5.x86_64.qcow2"
arch: "x86_64"
digest: "sha256:ca9e514cc2f4a7a0188e7c68af60eb4e573d2e6850cc65b464697223f46b4605"
- location: "https://download.fedoraproject.org/pub/fedora/linux/releases/36/Cloud/aarch64/images/Fedora-Cloud-Base-36-1.5.aarch64.qcow2"
arch: "aarch64"
digest: "sha256:5c0e7e99b0c542cb2155cd3b52bbf51a42a65917e52d37df457d1e9759b37512"

mounts:
- location: "~/go/src"
writable: true
containerd:
system: false
user: false
provision:
- mode: system
script: |
#!/bin/bash
set -eux -o pipefail
command -v podman >/dev/null 2>&1 && exit 0
if [ ! -e /etc/systemd/system/podman.socket.d/override.conf ]; then
mkdir -p /etc/systemd/system/podman.socket.d
cat <<-EOF >/etc/systemd/system/podman.socket.d/override.conf
[Socket]
SocketUser=${LIMA_CIDATA_USER}
EOF
fi
if [ ! -e /etc/tmpfiles.d/podman.conf ]; then
mkdir -p /etc/tmpfiles.d
echo "d /run/podman 0700 ${LIMA_CIDATA_USER} -" > /etc/tmpfiles.d/podman.conf
fi
dnf -y install podman
- mode: system
script: |
#!/bin/bash
set -eux -o pipefail
systemctl --system enable --now podman.socket
- mode: system
script: |
#!/bin/bash
set -eux -o pipefail
curl -LO https://go.dev/dl/go1.19.5.linux-$( [ $(uname -m) = aarch64 ] && echo arm64 || echo amd64).tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.5.linux-$( [ $(uname -m) = aarch64 ] && echo arm64 || echo amd64).tar.gz
dnf groupinstall -y "Development Tools" "Development Libraries"
- mode: user
script: |
#!/bin/bash
echo "export GOPATH=~/go" >> ~/.bashrc
echo "export PATH=~/go/bin:$PATH:/usr/local/go/bin" >> ~/.bashrc
probes:
- script: |
#!/bin/bash
set -eux -o pipefail
if ! timeout 30s bash -c "until command -v podman >/dev/null 2>&1; do sleep 3; done"; then
echo >&2 "podman is not installed yet"
exit 1
fi
hint: See "/var/log/cloud-init-output.log" in the guest
portForwards:
- guestSocket: "/run/podman/podman.sock"
hostSocket: "{{.Dir}}/sock/podman.sock"
message: |
To run `podman` on the host (assumes podman-remote is installed), run the following commands:
------
podman system connection add lima-{{.Name}} "unix://{{.Dir}}/sock/podman.sock"
podman system connection default lima-{{.Name}}
podman{{if eq .HostOS "linux"}} --remote{{end}} run quay.io/podman/hello
------

0 comments on commit dccc7a0

Please sign in to comment.