Skip to content

Commit

Permalink
Merge branch 'main' into laravel
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed May 6, 2024
2 parents 36e712e + fd17cd8 commit c9d7344
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 13 deletions.
37 changes: 36 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,43 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build image
run: make docker-build
- name: Test image
run: make docker-test

build-all-archs:
name: Push Docker image for all archs
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 2
matrix:
include:
# All non supported by base image are commented
# This is an example for the base image ruby (alpine variant)
- { platform: "linux/arm64", platform-tag: "arm64" }
- { platform: "linux/amd64", platform-tag: "amd64" }
- { platform: "linux/arm/v7", platform-tag: "armv7" }
- { platform: "linux/arm/v6", platform-tag: "armv6" }
- { platform: "linux/ppc64le", platform-tag: "ppc64le" }
#- { platform: "linux/riscv64", platform-tag: "riscv64" }
- { platform: "linux/s390x", platform-tag: "s390x" }
- { platform: "linux/386", platform-tag: "386" }
#- { platform: "linux/mips64le", platform-tag: "mips64le" }
#- { platform: "linux/mips64", platform-tag: "mips64" }
steps:
- name: Checkout repository
uses: actions/checkout@v4
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image
run: make docker-build
env:
DOCKER_BUILDKIT: 1
PLATFORM: ${{ matrix.platform }}
8 changes: 6 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_REPOSITORY_LOGIN }}
Expand All @@ -35,3 +35,7 @@ jobs:
private-key-id: "${{ secrets.DOCKER_PRIVATE_KEY_ID }}"
private-key: ${{ secrets.DOCKER_PRIVATE_KEY }}
private-key-passphrase: ${{ secrets.DOCKER_PRIVATE_KEY_PASSPHRASE }}
- name: Docker tag latest
run: docker tag docker.io/botsudo/capistrano:${{ steps.get_version.outputs.VERSION }} docker.io/botsudo/capistrano:latest
- name: Docker update latest
run: docker push docker.io/botsudo/capistrano:latest
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
IMAGE_TAG ?= capistrano-laravel
# All: linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6
PLATFORM ?= linux/amd64

ACTION ?= load
PROGRESS_MODE ?= plain

.PHONY: docker-build docker-test tag

docker-build:
docker build ./docker \
# https://github.com/docker/buildx#building
docker buildx build \
--build-arg VCS_REF="$(shell git rev-parse HEAD)" \
--build-arg BUILD_DATE="$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")" \
--build-arg RELEASE_VERSION="$(shell make version)" \
--tag $(IMAGE_TAG)
--tag $(IMAGE_TAG) \
--progress $(PROGRESS_MODE) \
--platform $(PLATFORM) \
--pull \
--$(ACTION) \
./docker

docker-test:
docker-compose -f ./docker/docker-compose-latest.test.yml up
Expand Down
23 changes: 15 additions & 8 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
FROM ruby:3-alpine3.16
FROM ruby:3-alpine3.19 as builder

ARG RELEASE_VERSION
COPY Gemfile ./

RUN apk add --update --no-cache make ruby-dev gcc musl-dev && \
gem install bundler --user-install && \
bundle install --no-cache && \
apk del gcc make musl-dev ruby-dev && \
rm -rf /usr/local/bundle/cache /root/.bundle

FROM ruby:3-alpine3.19

# Metadata params
ARG VCS_REF
ARG BUILD_DATE
ARG RELEASE_VERSION

WORKDIR /deploy

COPY Gemfile ./

RUN apk add --update --no-cache openssh-client make ruby-dev gcc musl-dev && \
gem install bundler --user-install && \
bundle install --no-cache && \
apk del gcc make musl-dev ruby-dev && \
rm -rf /usr/local/bundle/cache /root/.bundle
# We copy over the entire gems directory for our builder image, containing the already built artifact
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
RUN apk add --update --no-cache openssh-client && \
bundle exec cap --version && \
ssh-keyscan github.com

# Metadata
LABEL org.label-schema.vendor="Sudo-Bot" \
Expand Down

0 comments on commit c9d7344

Please sign in to comment.