From c7e6d2eebf4e1c5d643f15e4981f1d42021cbf32 Mon Sep 17 00:00:00 2001 From: Jan Hovancik Date: Sun, 3 Mar 2024 15:02:50 +0100 Subject: [PATCH] Up deps --- .devcontainer/Dockerfile | 6 ++++ .devcontainer/boot.sh | 19 ++++++++++++ .devcontainer/devcontainer.json | 51 ++++++++++++++++++++++++++++++++ .devcontainer/docker-compose.yml | 30 +++++++++++++++++++ .devcontainer/readme.md | 1 + .env.devcontainer | 4 +++ .github/workflows/tests.yml | 46 ++++++++++++++++++++++++++++ .node-version | 1 + .ruby-version | 2 +- Dockerfile | 4 +-- Gemfile | 2 +- fly.toml | 5 ++-- package.json | 2 +- 13 files changed, 166 insertions(+), 7 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100755 .devcontainer/boot.sh create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml create mode 100644 .devcontainer/readme.md create mode 100644 .env.devcontainer create mode 100644 .github/workflows/tests.yml create mode 100644 .node-version diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..1cfb0b5 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,6 @@ +FROM mcr.microsoft.com/vscode/devcontainers/base:ubuntu-22.04 + +# Adding the PostgreSQL repository so we can install postgresql-client v15 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null +RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' diff --git a/.devcontainer/boot.sh b/.devcontainer/boot.sh new file mode 100755 index 0000000..df7cb22 --- /dev/null +++ b/.devcontainer/boot.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +echo "Setting SSH password for vscode user..." +sudo usermod --password "$(echo vscode | openssl passwd -1 -stdin)" vscode + +echo "Updating RubyGems..." +gem update --system -N + +echo "Installing dependencies..." +bundle install +yarn install + +echo "Copying database.yml..." +cp -n .env.devcontainer .env + +echo "Creating database..." +bin/rails db:create db:migrate db:seed + +echo "Done!" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..4dfccd3 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,51 @@ +{ + "name": "Your Project Name", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "features": { + "ghcr.io/devcontainers/features/sshd:1": {}, + "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": { + "packages": "libpq-dev, libvips, postgresql-client-15" + }, + "ghcr.io/devcontainers/features/git:1": { + "version": "latest" + }, + "ghcr.io/devcontainers/features/ruby:1": { + "version": "3.2.2" + }, + "ghcr.io/devcontainers/features/node:1": { + "version": "16.19.0" + }, + "ghcr.io/devcontainers/features/common-utils:2": { + "username": "vscode", + "userUid": 1000, + "userGid": 1000, + "installZsh": true, + "installOhMyZsh": true, + "configureZshAsDefaultShell": true, + "upgradePackages": true + }, + "ghcr.io/devcontainers-contrib/features/zsh-plugins:0": { + "username": "vscode", + "plugins": "bundler rails ruby yarn" + } + }, + + // Configure tool-specific properties. + "customizations": { + "vscode": { + "extensions": ["Shopify.ruby-lsp"] + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // This can be used to network with other containers or the host. + "forwardPorts": [2222, 3000, 5433], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": ".devcontainer/boot.sh" + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..ae8a745 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,30 @@ +version: "3" + +services: + app: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + volumes: + - ../..:/workspaces:cached + command: sleep infinity + postgres: + image: postgres:15-alpine + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + ports: + - 5433:5432 + environment: + POSTGRES_USER: postgres + POSTGRES_DB: postgres + POSTGRES_PASSWORD: postgres + redis: + image: redis:7-alpine + restart: unless-stopped + volumes: + - redis-data:/data + +volumes: + postgres-data: + redis-data: diff --git a/.devcontainer/readme.md b/.devcontainer/readme.md new file mode 100644 index 0000000..e0b50f5 --- /dev/null +++ b/.devcontainer/readme.md @@ -0,0 +1 @@ +from https://github.com/luizkowalski/devcontainer-rails \ No newline at end of file diff --git a/.env.devcontainer b/.env.devcontainer new file mode 100644 index 0000000..9f7af77 --- /dev/null +++ b/.env.devcontainer @@ -0,0 +1,4 @@ +DATABASE_URL=postgres://postgres:postgres@postgres:5432/bsdsec_development +TEST_DATABASE_URL=postgres://postgres:postgres@postgres:5432/bsdsec_test +TEST_EMAIL=test@example.com +MAILGUN_INGRESS_API_KEY=asdf \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..31d5a1c --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,46 @@ +name: Tests +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-20.04 + services: + postgres: + image: postgres:10 + env: + POSTGRES_PASSWORD: postgres + ports: ['5432:5432'] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - uses: actions/checkout@v2 + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2.3 + - name: Install Bundler + run: gem install bundler + - name: Install Node + uses: actions/setup-node@v1 + with: + node-version: 16.19.0 + - name: Setup the Rails application + env: + RAILS_ENV: test + run: | + sudo apt-get -yqq install libpq-dev + bundle install --no-deployment --jobs 4 --retry 3 + cp config/database.github.yml config/database.yml + bundle exec rails db:create + bundle exec rails db:migrate + yarn --frozen-lockfile + - name: Run unit tests + run: bundle exec rails test + env: + CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} + - name: Publish code coverage + uses: paambaati/codeclimate-action@v2.7.5 + env: + CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..a336baf --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +16.19.0 \ No newline at end of file diff --git a/.ruby-version b/.ruby-version index 49cdd66..b347b11 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.6 +3.2.3 diff --git a/Dockerfile b/Dockerfile index 93cb3ea..53b1446 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM ruby:2.7.6 +FROM ruby:3.2.3 RUN apt-get update -qq RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - -RUN curl -sL https://deb.nodesource.com/setup_14.x | bash +RUN curl -sL https://deb.nodesource.com/setup_16.x | bash RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list RUN apt-get install -y nodejs RUN apt-get update && apt-get install -y yarn diff --git a/Gemfile b/Gemfile index 592e7bd..aadcc9c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -ruby "2.7.6" +ruby "3.2.3" # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.0' diff --git a/fly.toml b/fly.toml index 3cb9623..d31f416 100644 --- a/fly.toml +++ b/fly.toml @@ -1,14 +1,15 @@ -# fly.toml app configuration file generated for bsdsec on 2023-08-07T10:58:11+02:00 +# fly.toml app configuration file generated for bsdsec on 2023-09-15T18:52:57+02:00 # # See https://fly.io/docs/reference/configuration/ for information about how to use this file. # app = "bsdsec" +primary_region = "fra" kill_signal = "SIGINT" kill_timeout = "5s" [build] - builder = "heroku/buildpacks:20" + builder = "heroku/builder:22" buildpacks = ["heroku/nodejs", "heroku/ruby"] [build.args] SECRET_KEY_BASE = "asdf" diff --git a/package.json b/package.json index bbe3785..34b307c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "BSDSec", "private": true, "engines": { - "node": "14.x" + "node": "16.19.0" }, "dependencies": { "@fortawesome/fontawesome-free": "^5.11.2",