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

Remove mruby source code from docker image #11

Merged
merged 5 commits into from
Jun 2, 2024
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Build and push

on:
workflow_dispatch:
push:
branches:
- main
tags:
- '*'

jobs:
build:
uses: ./.github/workflows/docker_image_build.yml
with:
push: true
image_version: ${{ github.ref_name }}
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
jobs:
build:
uses: ./.github/workflows/docker_image_build.yml
with:
image_version: ${{ github.sha}}
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
8 changes: 3 additions & 5 deletions .github/workflows/docker_image_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
push:
default: false
type: boolean
mruby-version:
default: 'master'
image_version:
required: true
type: string
secrets:
dockerhub_username:
Expand All @@ -32,6 +32,4 @@ jobs:
context: ./docker
file: ./docker/Dockerfile
push: ${{ inputs.push }}
tags: ${{ secrets.dockerhub_username }}/mruby-build:${{ inputs.mruby-version }}
build-args: |
MRUBY_VERSION=${{ inputs.mruby-version }}
tags: ${{ secrets.dockerhub_username }}/mruby-build:${{ inputs.image_version }}
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
MRUBY_VERSION = ENV["MRUBY_VERSION"] || "3.2.0"
IMAGE_TAG = ENV["IMAGE_TAG"] || "buty4649/mruby-build:#{MRUBY_VERSION}"
git_sha = `git rev-parse HEAD`.chomp
IMAGE_TAG = ENV["IMAGE_TAG"] || "buty4649/mruby-build:#{git_sha}"

def no_cache_flag
"--no-cache" if ENV["NO_CAHE"]
end

desc "Build docker image"
task "build" do
sh "docker buildx build -t #{IMAGE_TAG} #{no_cache_flag} --build-arg MRUBY_VERSION=#{MRUBY_VERSION} docker/"
sh "docker buildx build -t #{IMAGE_TAG} #{no_cache_flag} docker/"
end
26 changes: 1 addition & 25 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,8 @@ RUN --mount=type=cache,target=/var/lib/apt <<COMMAND
gcc-mingw-w64 g++-mingw-w64 unzip xz-utils wget gosu jq
COMMAND

FROM base as source
ARG MRUBY_VERSION=3.2.0

RUN <<COMMAND
wget https://github.com/mruby/mruby/archive/${MRUBY_VERSION}.zip -O mruby.zip
unzip mruby.zip
mv mruby-${MRUBY_VERSION} mruby

if [ "${MRUBY_VERSION}" = "master" ]; then
REF="heads/master"
else
REF="tags/${MRUBY_VERSION}"
fi
wget -q -O - https://api.github.com/repos/mruby/mruby/commits/${REF} | jq -r '.sha' > /mruby/COMMIT
COMMAND

COPY mrbgems/mruby-commit-id /mruby/mrbgems/mruby-commit-id

RUN <<COMMAND
sed -i 's/%COMMIT_ID%/'`cat /mruby/COMMIT`'/' /mruby/mrbgems/mruby-commit-id/src/commit_id.c
COMMAND

FROM base as zig
ARG ZIG_VERSION=0.11.0
ARG ZIG_VERSION=0.12.0
ENV ZIG_MINISIGN_PUBKEY=RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U

RUN <<COMMAND
Expand Down Expand Up @@ -63,8 +41,6 @@ RUN rm -r MacOSX.sdk/usr/share/man

FROM base

COPY --from=source /mruby /mruby

COPY --from=zig zig /usr/local/share/zig
RUN ln -s /usr/local/share/zig/zig /usr/local/bin/zig

Expand Down
2 changes: 1 addition & 1 deletion docker/Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'fileutils'

mruby_root = "/mruby"
mruby_root = File.expand_path(ENV["MRUBY_ROOT"] || "./mruby")
build_config = File.expand_path(ENV["MRUBY_CONFIG"] || "build_config.rb")
build_dir = File.expand_path(ENV["MRUBY_BUILD_DIR"] || "build")
install_dir = File.expand_path(ENV["MRUBY_INSTALL_DIR"] || "build/bin")
Expand Down
5 changes: 0 additions & 5 deletions docker/mrbgems/mruby-commit-id/mrbgem.rake

This file was deleted.

10 changes: 0 additions & 10 deletions docker/mrbgems/mruby-commit-id/src/commit_id.c

This file was deleted.

Loading