Skip to content

Commit

Permalink
Update Dockerfile (#31) (#38)
Browse files Browse the repository at this point in the history
* Update Dockerfile (#31)

* refactored to use /scripts/builder.sh instead of Dockerfile creating builder.sh in builder_rootless and builder_client

* minor fixes in Dockerfile and /scripts/builder.sh

* Update dockerignore file

* Update .dockerignore

* Update builder.sh

* Update builder.sh

* Update Dockerfile

---------

Co-authored-by: Vicente Eduardo Ferrer Garcia <[email protected]>
  • Loading branch information
SaranshBaniyal and viferga authored Nov 21, 2024
1 parent 51b0eec commit c6b4555
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
!pkg
!go.mod
!go.sum
!scripts/builder.sh
29 changes: 7 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,17 @@ ENTRYPOINT ["/builder"]
# Builder Image Rootless
FROM moby/buildkit:master-rootless AS builder_rootless

COPY --from=builder_binary --chown=user:user /builder /home/user/builder

# TO-DO : Replace with copying from scripts locally
RUN printf '#!/bin/sh\n\
export BUILDKITD_FLAGS=--oci-worker-no-process-sandbox\n\
/home/user/builder $@ | buildctl-daemonless.sh build \
--export-cache type=registry,ref=${EXPORT_REGISTRY},registry.insecure=true \
--import-cache type=registry,ref=${IMPORT_REGISTRY},registry.insecure=true \
--output type=image,name=registry:5000/metacall/builder_output_$1,push=true,registry.insecure=true\n'\
>> /home/user/builder.sh \
&& chmod 700 /home/user/builder.sh \
&& chmod 700 /home/user/builder
COPY --from=builder_binary --chown=user:user --chmod=700 /builder /home/user/builder

# Copy the local builder.sh script from the scripts folder
COPY --chown=user:user --chmod=700 ./scripts/builder.sh /home/user/builder.sh

# Builder Image
FROM moby/buildkit AS builder_client

COPY --from=builder_binary --chown=root:root /builder /home/builder
COPY --from=builder_binary --chown=root:root --chmod=700 /builder /home/builder

RUN apk add --no-cache docker

# TO-DO : Replace with copying from scripts locally
RUN printf '#!/bin/sh\n\
/home/builder $@ | buildctl --addr="docker-container://metacall_builder_buildkit" build \
--export-cache type=registry,ref=${EXPORT_REGISTRY},registry.insecure=true \
--import-cache type=registry,ref=${IMPORT_REGISTRY},registry.insecure=true \
--output type=image,name=registry:5000/metacall/builder_output_$1,push=true,registry.insecure=true\n'\
>> /home/builder.sh \
&& chmod 700 /home/builder.sh \
&& chmod 700 /home/builder
# Copy the local builder.sh script from the scripts folder
COPY --chown=root:root --chmod=700 ./scripts/builder.sh /home/builder.sh
14 changes: 7 additions & 7 deletions scripts/builder.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh\n\
export BUILDKITD_FLAGS=--oci-worker-no-process-sandbox\n\
#!/bin/sh

export BUILDKITD_FLAGS=--oci-worker-no-process-sandbox

if [ -z "$EXPORT_REGISTRY" ]; then
EXPORT_REGISTRY="registry:5000/metacall/builder_cache"
Expand All @@ -10,11 +11,10 @@ if [ -z "$IMPORT_REGISTRY" ]; then
fi

if [ -z "$BUILDER_BINARY" ]; then
BUILDER_BINARY="/home/user/builder"
BUILDER_BINARY="${HOME}/builder"
fi


${BUILDER_BINARY} $@ | buildctl-daemonless.sh build \
--export-cache type=registry,ref=${EXPORT_REGISTRY},registry.insecure=true \
--import-cache type=registry,ref=${IMPORT_REGISTRY},registry.insecure=true \
--output type=image,name=registry:5000/metacall/builder_output,push=true,registry.insecure=true\n'\
--export-cache type=registry,ref=${EXPORT_REGISTRY},registry.insecure=true \
--import-cache type=registry,ref=${IMPORT_REGISTRY},registry.insecure=true \
--output type=image,name=registry:5000/metacall/builder_output,push=true,registry.insecure=true

0 comments on commit c6b4555

Please sign in to comment.