Skip to content

Instantly share code, notes, and snippets.

View michalkorzawski's full-sized avatar

michalkorzawski

View GitHub Profile
version: '3.8'
services:
jenkins:
image: jenkins/jenkins:jdk11
environment:
- JAVA_OPTS=-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true -Dhudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION=true
ports:
- 8080:8080
volumes:
- jenkins_home:/var/jenkins_home
version: '3.8'
services:
jenkins:
environment:
- JAVA_OPTS=-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true
image: jenkins/jenkins:jdk11
ports:
- 8080:8080
volumes:
- jenkins_home:/var/jenkins_home
version: '3.8'
services:
jenkins:
image: jenkins/jenkins:jdk11
ports:
- 8080:8080
volumes:
- jenkins_home:/var/jenkins_home
volumes:
FROM anycable/anycable-go:1.2
ENV ANYCABLE_HOST=0.0.0.0
ENV ANYCABLE_REDIS_URL=redis://redis:6379/0
ENV ANYCABLE_RPC_HOST=anycable:50051
ENV ANYCABLE_DEBUG=1
ENV ANYCABLE_PORT=8085
EXPOSE 50051
version: "3.3"
x-image-build: &image_build
env_file: .env
build:
context: .
dockerfile: Dockerfile.development
stdin_open: true
tty: true
# app/controllers/images_controller.rb
class ImagesController < ApplicationController
skip_before_action :verify_authenticity_token, only: :convert_heic
def convert_heic
tempfile = ImageConverter.new(tempfile: params[:image].tempfile, height: 400).call
render json: tempfile.read, content_type: 'image/jpg'
end
end
// app/javascript/controllers/image_preview_controller.js
import ApplicationController from "./application_controller";
export default class extends ApplicationController {
static targets = ["imagePreview"];
...
# app/services/image_converter.rb
class ImageConverter
def initialize(tempfile:, width: nil, height: nil, type: 'jpg')
@tempfile = tempfile
@width = width
@height = height
@type = type
end
# app/controllers/records_controller.rb
def some_method
... business logic ...
attaching_images = params[:record][:images].presence
if attaching_images
attaching_images = attaching_images.map do |im|
tempfile = ImageConverter.new(tempfile: im.tempfile, width: 1200).call
ActionDispatch::Http::UploadedFile.new(