Skip to content

Instantly share code, notes, and snippets.

@r3cha
r3cha / docker-compose.css-and-js.yml
Last active August 12, 2024 09:31
Two separate services for assets compilation with cssbundling-rails and jsbundling-rails
services:
css:
image: initapp-rails
env_file:
- .docker.env
- .env
volumes:
- ./:/app:c
- cache:/app/tmp/cache:d
- bundle:/usr/local/bundle:ro
@r3cha
r3cha / compose.yaml
Last active August 16, 2024 09:02
Docker compose
name: Initapp-rails
services:
app:
image: initapp-rails
build:
context: .
target: development
env_file:
- .docker.env
@r3cha
r3cha / Dockerfile
Last active August 12, 2024 09:32
Dockerfile
FROM ruby:3.2.5-slim-bullseye AS development
COPY --from=node:20.16.0-bullseye-slim /usr/local/bin/node /usr/local/bin/
COPY --from=node:20.16.0-bullseye-slim /usr/local/lib/node_modules /usr/local/lib/node_modules
COPY --from=node:20.16.0-bullseye-slim /opt/yarn-v1.22.22 /opt/yarn-v1.22.22
RUN ln -s /usr/local/bin/node /usr/local/bin/nodejs && \
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx && \
ln -s /usr/local/lib/node_modules/corepack/dist/corepack.js /usr/local/bin/corepack && \
@r3cha
r3cha / deploy_compose.yml
Created August 5, 2024 09:58
Simple deploy using docker compose and reproxy
# NOTE: github actions at ./.github/workflows/ folder
# NOTE: generate ssh keypair at server, put pub key into authorized_keys at server and private key as SERVER github secrets
name: 'Build docker image, run tests and deploy'
on:
push:
jobs:
build:
name: Deploy docker-compose.prod.yml
def perform(url)
return unless url
response = HTTParty.get(url)
return unless response.success?
data = JSON.parse(response.body)
return unless data['results']
data['results'].each do |test|
@r3cha
r3cha / Dockerfile
Last active September 3, 2020 10:27
One app docker image for build frontend & backend
FROM node:14-alpine as node
FROM ruby:2.7.0-alpine3.11 as build-base
COPY --from=node /usr/local/bin/node /usr/local/bin/
COPY --from=node /opt/yarn-v1.22.4 /opt/yarn-v1.22.4
RUN ln -s /usr/local/bin/node /usr/local/bin/nodejs
# Here is you can copy npm from node to build-base if you preffer use it
RUN ln -s /opt/yarn-v1.22.4/bin/yarn /usr/local/bin/yarn
@r3cha
r3cha / docker-compose.yml
Last active September 4, 2020 10:58
Fastest way to up you frontend service
version: "3.8"
volumes:
node_modules:
services:
ui:
image: node:14.8.0-alpine3.12
ports:
- 3000:8080
@r3cha
r3cha / user_jwt.rb
Last active May 27, 2020 09:23
Mongoid Rails model concern
# app/models/concerns/user_jwt.rb
module UserJwt
extend ActiveSupport::Concern
included do
include ActiveModel::SecurePassword
has_secure_password
field :email, type: String
field :phone, type: String
FROM node:current-alpine3.11 as node
FROM ruby:2.6.5-alpine3.11 as build-base
COPY --from=node /usr/local/bin/node /usr/local/bin/
COPY --from=node /opt/yarn-v1.22.0 /opt/yarn-v1.22.0
RUN ln -s /usr/local/bin/node /usr/local/bin/nodejs
RUN ln -s /opt/yarn-v1.22.0/bin/yarn /usr/local/bin/yarn
RUN ln -s /opt/yarn-v1.22.0/bin/yarnpkg /usr/local/bin/yarnpkg
@r3cha
r3cha / Gemfile
Last active April 6, 2019 16:03
Create Ruby on Rails application from bootstrap theme
# add this gems to Gemfile
gem 'bootstrap', '~> 4.3.1'
gem 'jquery-rails'
gem 'popper_js', '~> 1.14.5'