mirror of
https://github.com/internetee/registry.git
synced 2025-05-31 18:03:56 +02:00
Preinstalled gems base image (#2208)
* Builds from baseimage with gems preinstalled * Checks for changes in Gemfile * Different conditional steps for build dockerfile selection * Builds new latest gems base image if new gems are added to master
This commit is contained in:
parent
c5719a35f1
commit
00bb2ffb45
4 changed files with 83 additions and 4 deletions
32
.github/workflows/build_baseimage_with_gems.yml
vendored
Normal file
32
.github/workflows/build_baseimage_with_gems.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
name: build baseimage with gems
|
||||||
|
|
||||||
|
on:
|
||||||
|
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- "Gemfile"
|
||||||
|
- "Gemfile.lock"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Login to container registry
|
||||||
|
env:
|
||||||
|
PASSWORD: ${{ secrets.GHCR }}
|
||||||
|
run: |
|
||||||
|
echo $PASSWORD | docker login ghcr.io -u eisbot --password-stdin
|
||||||
|
|
||||||
|
- name: Build new image with gems
|
||||||
|
run: |
|
||||||
|
docker build --no-cache -t ghcr.io/internetee/registry:gems-latest -f Dockerfile.gems .
|
||||||
|
docker push ghcr.io/internetee/registry:gems-latest
|
||||||
|
|
31
.github/workflows/build_deploy_staging.yml
vendored
31
.github/workflows/build_deploy_staging.yml
vendored
|
@ -26,6 +26,32 @@ jobs:
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Check if there are gem updates
|
||||||
|
id: gem-updates-check
|
||||||
|
uses: tj-actions/changed-files@aae164d51be780a235cdeea89752bbacbbfee3c3
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
Gemfile
|
||||||
|
Gemfile.lock
|
||||||
|
|
||||||
|
- name: Login to container registry
|
||||||
|
env:
|
||||||
|
PASSWORD: ${{ secrets.GHCR }}
|
||||||
|
run: |
|
||||||
|
echo $PASSWORD | docker login ghcr.io -u eisbot --password-stdin
|
||||||
|
|
||||||
|
- name: No changes in gems
|
||||||
|
# feature branch has no changes in gems
|
||||||
|
if: steps.gem-updates-check.outputs.any_changed == 'false'
|
||||||
|
run: |
|
||||||
|
echo "DOCKERFILE=Dockerfile.preinstalled_gems" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Gems are changed
|
||||||
|
# feature branch has new/updated gems
|
||||||
|
if: steps.gem-updates-check.outputs.any_changed == 'true'
|
||||||
|
run: |
|
||||||
|
echo "DOCKERFILE=Dockerfile.generic" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Set image tag
|
- name: Set image tag
|
||||||
run: |
|
run: |
|
||||||
SHORT_SHA=$(echo $GITHUB_SHA | cut -c 1-7) #pr-s test commit of merged state
|
SHORT_SHA=$(echo $GITHUB_SHA | cut -c 1-7) #pr-s test commit of merged state
|
||||||
|
@ -55,7 +81,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
KEY_BASE: ${{ secrets.KEY_BASE}}
|
KEY_BASE: ${{ secrets.KEY_BASE}}
|
||||||
run: |
|
run: |
|
||||||
docker build -t $TAG --build-arg RAILS_ENV=staging --build-arg SECRET_KEY_BASE="$KEY_BASE" -f Dockerfile.generic .
|
docker build -t $TAG --build-arg RAILS_ENV=staging --build-arg SECRET_KEY_BASE="$KEY_BASE" -f $DOCKERFILE .
|
||||||
|
|
||||||
- name: Clone epp_proxy project
|
- name: Clone epp_proxy project
|
||||||
run: |
|
run: |
|
||||||
|
@ -82,10 +108,7 @@ jobs:
|
||||||
docker build -t $PROXY_TAG -f Dockerfile.release .
|
docker build -t $PROXY_TAG -f Dockerfile.release .
|
||||||
|
|
||||||
- name: Push Docker image to gh container registry
|
- name: Push Docker image to gh container registry
|
||||||
env:
|
|
||||||
PASSWORD: ${{ secrets.GHCR }}
|
|
||||||
run: |
|
run: |
|
||||||
echo $PASSWORD | docker login ghcr.io -u eisbot --password-stdin
|
|
||||||
docker push $TAG
|
docker push $TAG
|
||||||
docker push $PROXY_TAG
|
docker push $PROXY_TAG
|
||||||
|
|
||||||
|
|
5
Dockerfile.gems
Normal file
5
Dockerfile.gems
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
FROM internetee/ruby_base:3.0
|
||||||
|
LABEL org.opencontainers.image.source=https://github.com/internetee/registry
|
||||||
|
|
||||||
|
COPY Gemfile Gemfile.lock ./
|
||||||
|
RUN gem install bundler && bundle config set without 'development test' && bundle install --jobs 20 --retry 5
|
19
Dockerfile.preinstalled_gems
Normal file
19
Dockerfile.preinstalled_gems
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
FROM ghcr.io/internetee/registry:gems-latest
|
||||||
|
LABEL org.opencontainers.image.source=https://github.com/internetee/registry
|
||||||
|
ARG YARN_VER='1.22.10'
|
||||||
|
ARG RAILS_ENV
|
||||||
|
ARG SECRET_KEY_BASE
|
||||||
|
|
||||||
|
ENV RAILS_ENV "$RAILS_ENV"
|
||||||
|
ENV SECRET_KEY_BASE "$SECRET_KEY_BASE"
|
||||||
|
|
||||||
|
RUN npm install -g yarn@"$YARN_VER"
|
||||||
|
|
||||||
|
RUN mkdir -p /opt/webapps/app/tmp/pids
|
||||||
|
WORKDIR /opt/webapps/app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN bundle exec rails assets:precompile
|
||||||
|
|
||||||
|
EXPOSE 3000
|
Loading…
Add table
Add a link
Reference in a new issue