Skip to content

Commit

Permalink
Build CI container in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotjordan committed Sep 30, 2024
1 parent 468ac5b commit 69467a0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .circleci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM cimg/ruby:3.1.0-browsers
FROM cimg/ruby:3.1.6-browsers

RUN sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
&& wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
Expand Down
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
test:
working_directory: ~/figgy
docker:
- image: pulibrary/ci-figgy:1.6
- image: ghcr.io/pulibrary/figgy:latest
environment:
RAILS_ENV: test
FIGGY_DB_HOST: localhost
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/build-ci-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Create and publish a Docker CI image

on:
push:
paths:
- .circleci/Dockerfile
- bin/**
branches:
- main
pull_request:
paths:
- .circleci/Dockerfile
- bin/**
branches:
- main
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha
env:
DOCKER_METADATA_PR_HEAD_SHA: true

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: "${{ github.workspace }}"
file: "${{ github.workspace }}/.circleci/Dockerfile"
push: true
tags: ghcr.io/pulibrary/figgy:ci
labels: ${{ steps.meta.outputs.labels }}
4 changes: 2 additions & 2 deletions app/derivative_services/geo_derivatives/processors/gdal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def self.compress(in_path, out_path, options)
# @param options [Hash] creation options
def self.cloud_optimized_geotiff(in_path, out_path, _options)
execute("gdal_translate -q -expand rgb \"#{in_path}\" #{out_path} -ot Byte -of COG "\
"-a_nodata 256 -co COMPRESS=JPEG")
"-a_nodata 256 -co COMPRESS=LZW")
rescue StandardError
# Try without expanding rgb
execute("gdal_translate -q \"#{in_path}\" #{out_path} -ot Byte -of COG "\
"-a_nodata 256 -co COMPRESS=JPEG")
"-a_nodata 256 -co COMPRESS=LZW")
end

# Executes a gdal_rasterize command. Used to rasterize vector
Expand Down

0 comments on commit 69467a0

Please sign in to comment.