Skip to content

Commit

Permalink
Trying to add a registry to push the images.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Jun 18, 2024
1 parent bcbbcab commit bc12aad
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 299 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.go text eol=lf
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ jobs:
with:
fetch-depth: 0

# TODO:
# - name: Lint
# run: docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.59.1 golangci-lint run -v --enable-all

- name: Build
run: docker compose build
run: docker compose build

- name: Test Binary
run: ./test/test.sh binary
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Main executable
main

# Registry shared folder
registry/data/**
!registry/data/.gitkeep

# Binaries for programs and plugins
*.exe
*.exe~
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ COPY --from=builder_binary --chown=user:user /builder /home/user/builder

RUN printf '#!/bin/sh\n\
export BUILDKITD_FLAGS=--oci-worker-no-process-sandbox\n\
/home/user/builder $@ | buildctl-daemonless.sh build --output type=image,name=docker.io/metacall/builder_output,push=false\n'\
/home/user/builder $@ | buildctl-daemonless.sh build --output type=image,name=registry:5000/metacall/builder_output,push=true\n'\
>> /home/user/builder.sh \
&& chmod 700 /home/user/builder.sh \
&& chmod 700 /home/user/builder
Expand All @@ -47,7 +47,7 @@ COPY --from=builder_binary --chown=root:root /builder /home/builder
RUN apk add --no-cache docker

RUN printf '#!/bin/sh\n\
/home/builder $@ | buildctl --addr="docker-container://metacall_builder_buildkit" build --output type=docker,name=docker.io/metacall/builder_output | docker load\n'\
/home/builder $@ | buildctl --addr="docker-container://metacall_builder_buildkit" build --output type=image,name=registry:5000/metacall/builder_output,push=true\n'\
>> /home/builder.sh \
&& chmod 700 /home/builder.sh \
&& chmod 700 /home/builder
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ BUILDER_ARGS="runtime py" docker compose up --exit-code-from client client

Rootless:
```sh
BUILDER_ARGS="runtime node" docker compose up rootless
BUILDER_ARGS="runtime node" docker compose up --exit-code-from rootless rootless
```

You can also run the builder binary only:

```sh
BUILDER_ARGS="runtime rb" docker compose up binary
BUILDER_ARGS="runtime rb" docker compose up --exit-code-from binary binary
```

## Linter

```sh
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.59.1 golangci-lint run -v --enable-all
```

## Useful Tools
Expand Down
29 changes: 21 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.7"

volumes:
buildkit:
# volumes:
# buildkit:

services:
binary:
Expand All @@ -24,7 +24,9 @@ services:
security_opt:
- "seccomp=unconfined"
- "apparmor=unconfined"
network_mode: "host"
# network_mode: "host"
depends_on:
- registry

client:
image: metacall/builder_client
Expand All @@ -36,21 +38,32 @@ services:
entrypoint: /home/builder.sh ${BUILDER_ARGS:-}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- buildkit:/run/user/1000/buildkit/buildkitd.sock
# - buildkit:/run/user/1000/buildkit/buildkitd.sock
depends_on:
- buildkit
- registry

buildkit:
image: moby/buildkit
container_name: metacall_builder_buildkit
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /run/containerd/containerd.sock:/run/containerd/containerd.sock
- buildkit:/run/buildkit/buildkitd.sock
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock
# - /run/containerd/containerd.sock:/run/containerd/containerd.sock
# - buildkit:/run/buildkit/buildkitd.sock
healthcheck:
test: buildctl debug workers
interval: 5s
timeout: 30s
retries: 3
start_period: 1s

registry:
image: registry:2.8
container_name: metacall_builder_registry
restart: always
ports:
- 5000:5000
volumes:
- ./registry/config.yml:/etc/docker/registry/config.yml:ro
- ./registry/data:/var/lib/registry:rw
3 changes: 3 additions & 0 deletions docker/daemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"registry-mirrors": ["http://metacall_builder_registry:5000/"]
}
255 changes: 0 additions & 255 deletions main_backup.go

This file was deleted.

Loading

0 comments on commit bc12aad

Please sign in to comment.