Skip to content

Switch to Ansible-Free Docker Image for Devstack #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: RUBY CI
name: CI

on:
push:
Expand All @@ -13,11 +13,12 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
ruby-version: ['3.0.4']
ruby-version: ['3.2.2']
mongodb-version: ['4.2.14']
elasticsearch-version: ['7.8.0']
include:
- ruby-version: 3.0.4
gemfile: Gemfile3
- ruby-version: 3.2.2
gemfile: Gemfile
allow-failure: false
env:
SEARCH_SERVER_ES7: http://localhost:9200
Expand All @@ -31,7 +32,7 @@ jobs:
RACK_TIMEOUT_SERVICE_TIMEOUT: 20
services:
elasticsearch:
image: elasticsearch:7.8.0
image: elasticsearch:${{ matrix.elasticsearch-version }}
env:
discovery.type: single-node
bootstrap.memory_lock: true
Expand All @@ -48,7 +49,7 @@ jobs:
- 27017:27017
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/push-docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build and Push Docker Images

on:
push:
branches:
- master
- open-release/**

jobs:
push:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v4

# Use the release name as the image tag if we're building an open release tag.
# Examples: if we're building 'open-release/maple.1', tag the image as 'maple.1'.
# Otherwise, we must be building from a push to master, so use 'latest'.
- name: Get tag name
id: get-tag-name
uses: actions/github-script@v6
with:
script: |
const releasePrefix = 'refs/tags/open-release/';
const tagName = context.ref.split(releasePrefix)[1] || 'latest';
console.log('Will use tag: ' + tagName);
return tagName;
result-encoding: string

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push base Docker image
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name != 'pull_request' }}
target: base
repository: edxops/forum
tags: |
edxops/forum:${{ steps.get-tag-name.outputs.result }}
edxops/forum:${{ github.sha }}
platforms: linux/amd64,linux/arm64
75 changes: 75 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
FROM ubuntu:focal as app

ENV DEBIAN_FRONTEND noninteractive

ENV RUBY_VERSION 3.2.2

# System requirements.
RUN apt update && \
apt upgrade -y && \
apt install -qy \
git \
# ubuntu locale support so that system utilities have a consistent language and time zone.
language-pack-en \
locales \
curl \
autoconf \
bison \
build-essential \
libssl-dev \
libyaml-dev \
libreadline6-dev \
zlib1g-dev \
libncurses5-dev \
libffi-dev \
libgdbm6 \
libgdbm-dev \
libdb-dev \
&& \
# delete apt package lists because we do not need them inflating our image
rm -rf /var/lib/apt/lists/*

# Use UTF-8.
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# Install Ruby
RUN curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
ENV PATH=/root/.rbenv/shims:/root/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
RUN echo 'eval "$(rbenv init -)"' >> .bashrc

RUN rbenv install $RUBY_VERSION
RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc
RUN rbenv global $RUBY_VERSION
RUN ruby --version
RUN gem update --system

ARG COMMON_APP_DIR="/edx/app"
ARG CS_COMMENTS_SERVICE_NAME="cs_comments_service"
ARG CS_COMMENTS_SERVICE_APP_DIR="${COMMON_APP_DIR}/forum/${CS_COMMENTS_SERVICE_NAME}"

WORKDIR ${CS_COMMENTS_SERVICE_APP_DIR}
EXPOSE 4567

FROM app as dev

COPY ./Gemfile ${CS_COMMENTS_SERVICE_APP_DIR}/Gemfile
COPY ./Gemfile.lock ${CS_COMMENTS_SERVICE_APP_DIR}/Gemfile.lock
COPY . ${CS_COMMENTS_SERVICE_APP_DIR}

RUN bundle install

CMD while true; do unicorn -c /edx/app/forum/cs_comments_service/config/unicorn_tcp.rb -I '.'; sleep 2; done

FROM app as prod

COPY ./Gemfile ${CS_COMMENTS_SERVICE_APP_DIR}/Gemfile
COPY ./Gemfile.lock ${CS_COMMENTS_SERVICE_APP_DIR}/Gemfile.lock
COPY . ${CS_COMMENTS_SERVICE_APP_DIR}

RUN bundle install

CMD ["unicorn", "--workers=2", "--name", "forum", "-c", "/edx/app/forum/cs_comments_service/config/unicorn_tcp.rb", "-I", ".", "--log-file", "-", "--max-requests=1000"]
94 changes: 47 additions & 47 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
source 'https://rubygems.org'
ruby "2.5.7"
source "https://rubygems.org"

gem 'pry'
gem 'pry-nav'
ruby "~> 3.2.2"

gem "pry"
gem "pry-nav"

# Use with command-line debugging, but not RubyMine
#gem 'debugger'
# gem "debugger"

gem 'bundler'
gem "bundler"

gem 'rake'
gem "rake"

gem 'sinatra'
gem 'sinatra-param', '~> 1.4'
gem "sinatra"
gem "sinatra-param"

gem 'yajl-ruby', '~> 1.3.1'
gem "yajl-ruby"

gem 'activemodel'
gem 'protected_attributes_continued'
gem "activemodel"
gem "protected_attributes_continued"

gem 'mongoid'
gem 'bson'
gem 'bson_ext'
gem "mongoid"
gem "bson"
gem "bson_ext"

gem 'delayed_job'
gem 'delayed_job_mongoid'
gem "delayed_job"
gem "delayed_job_mongoid"

gem "enumerize"
gem 'mongoid-tree', :git => 'https://github.com/edx/mongoid-tree'
gem 'rs_voteable_mongo', '~> 1.3'
gem 'mongoid_magic_counter_cache'
gem "mongoid-tree"
gem "rs_voteable_mongo"
gem "mongoid_magic_counter_cache"

# Before updating will_paginate version, we need to make sure that property 'total_entries'
# exists otherwise use updated property name to fetch total collection count in lib/helpers.rb's
# function 'handle_threads_query'.
gem 'will_paginate_mongoid', "~>2.0"
gem 'rdiscount'
gem 'nokogiri', "~> 1.8.1"
# Before updating will_paginate version, we need to make sure that property "total_entries"
# exists otherwise use updated property name to fetch total collection count in lib/helpers.rb"s
# function "handle_threads_query".
gem "will_paginate_mongoid", "~>2.0"
gem "rdiscount"
gem "nokogiri"

gem 'elasticsearch', '~> 7.8.0'
gem 'elasticsearch-model', '~> 7.1.0'
gem "elasticsearch", "~> 7.13.3"
gem "elasticsearch-model", "~> 7.2.1"

gem 'dalli'
gem "dalli"

gem 'rest-client'
gem "rest-client"

group :test do
gem 'codecov', :require => false
gem 'mongoid_cleaner', '~> 1.2.0'
gem 'factory_bot'
gem 'faker'
gem 'guard'
gem 'guard-unicorn'
gem 'rack-test', :require => 'rack/test'
gem 'rspec'
gem 'rspec-its'
gem 'rspec-collection_matchers'
gem 'webmock'
gem "codecov", :require => false
gem "mongoid_cleaner"
gem "factory_bot"
gem "faker"
gem "guard"
gem "guard-unicorn"
gem "rack-test", :require => "rack/test"
gem "rspec"
gem "rspec-its"
gem "rspec-collection_matchers"
gem "webmock"
end

group 'newrelic_rpm' do
gem 'newrelic_rpm'
group "newrelic_rpm" do
gem "newrelic_rpm"
end

gem 'unicorn'
gem "unicorn"
gem "rack-timeout"
gem "i18n"
gem "rack-contrib", :git => 'https://github.com/rack/rack-contrib.git', :ref => '6ff3ca2b2d988911ca52a2712f6a7da5e064aa27'

gem "rack-contrib"

gem "timecop", "~> 0.9.5"
gem "timecop"
Loading