Skip to content
Merged
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
84 changes: 45 additions & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#################################
# Build the support container
FROM ruby:2.6.5-slim-stretch as base
FROM ruby:2.6.5-slim-stretch AS base
LABEL edu.northwestern.library.app=Arch \
edu.northwestern.library.stage=build \
edu.northwestern.library.role=support
Expand All @@ -21,31 +21,30 @@ RUN sed -i '/stretch-updates/d' /etc/apt/sources.list && \

RUN apt-get update -qq && \
apt-get install -y $BUILD_DEPS --no-install-recommends

RUN \
# Set locale
dpkg-reconfigure -f noninteractive tzdata && \

# Set locale
RUN dpkg-reconfigure -f noninteractive tzdata && \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8 && \
\
mkdir -p /tmp/stage/bin && \
\
# Install FFMPEG
mkdir -p /tmp/ffmpeg && \
mkdir -p /tmp/stage/bin

# Install FFMPEG
RUN mkdir -p /tmp/ffmpeg && \
cd /tmp/ffmpeg && \
curl https://s3.amazonaws.com/nul-repo-deploy/ffmpeg-release-64bit-static.tar.xz | tar xJ && \
cp `find . -type f -executable` /tmp/stage/bin/ && \
\
# Install FITS
cd /tmp && \
cp `find . -type f -executable` /tmp/stage/bin/

# Install FITS
RUN cd /tmp && \
curl -O https://s3.amazonaws.com/nul-repo-deploy/fits-${FITS_VERSION}.zip && \
cd /tmp/stage && \
unzip -o /tmp/fits-${FITS_VERSION}.zip && \
\
# Update bundler
gem install rubygems-update --version 3.3.24 && \
unzip -o /tmp/fits-${FITS_VERSION}.zip

# Update bundler
RUN gem install rubygems-update --version 3.3.24 && \
update_rubygems && \
gem install bundler --version 2.3.8

Expand All @@ -64,7 +63,7 @@ RUN chown -R app:app /home/app && \

#################################
# Build the Application container
FROM ruby:2.6.5-slim-stretch as app
FROM ruby:2.6.5-slim-stretch AS app
LABEL edu.northwestern.library.app=Arch \
edu.northwestern.library.stage=run \
edu.northwestern.library.role=app
Expand All @@ -86,35 +85,42 @@ RUN sed -i '/stretch-updates/d' /etc/apt/sources.list && \

RUN mkdir -p /usr/share/man/man1 /usr/share/man/man7 && \
apt-get update -qq && \
apt-get install -y curl gnupg2 --no-install-recommends && \
# Install NodeJS and Yarn package repos
curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
apt-get install -y ca-certificates curl gnupg2 --no-install-recommends

# Install NodeJS and Yarn package repos
RUN curl -sL https://deb.nodesource.com/setup_12.x | sed '/deprecation_warning$/ s/^/#/' | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
# Install runtime dependencies
apt-get update -qq && \
apt-get install -y $RUNTIME_DEPS --no-install-recommends && \
# Install webpack
alias nodejs=node && \
yarn add webpack && \
# Set locale
dpkg-reconfigure -f noninteractive tzdata && \
echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

# Install runtime dependencies
RUN apt-get update -qq && \
apt-get install -y $RUNTIME_DEPS --no-install-recommends

# Install webpack
RUN alias nodejs=node && \
yarn add webpack

# Set locale
RUN dpkg-reconfigure -f noninteractive tzdata && \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8 && \
# Install VIPS
cd /tmp && \
update-locale LANG=en_US.UTF-8

# Install VIPS
RUN cd /tmp && \
curl -sO https://s3.amazonaws.com/nul-repo-deploy/packages/libvips-tools_8.7.4-1_amd64.deb && \
curl -sO https://s3.amazonaws.com/nul-repo-deploy/packages/libvips-dev_8.7.4-1_amd64.deb && \
curl -sO https://s3.amazonaws.com/nul-repo-deploy/packages/libvips42_8.7.4-1_amd64.deb && \
curl -sO https://s3.amazonaws.com/nul-repo-deploy/packages/gir1.2-vips-8.0_8.7.4-1_amd64.deb && \
apt-get install -y $(find . -name '*.deb') && \
# Clean up package cruft
apt-get clean -y && \
rm -rf /var/lib/apt/lists/* /tmp/*.deb && \
# Update Bundler
gem install rubygems-update --version 3.3.24 && \
apt-get install -y $(find . -name '*.deb')

# Clean up package cruft
RUN apt-get clean -y && \
rm -rf /var/lib/apt/lists/* /tmp/*.deb

# Update Bundler
RUN gem install rubygems-update --version 3.3.24 && \
update_rubygems && \
gem install bundler --version 2.3.8

Expand Down
1 change: 1 addition & 0 deletions app/views/cookie_consent/_content.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a href="#" class="cky-banner-element">Cookie Settings</a>
2 changes: 2 additions & 0 deletions app/views/cookie_consent/_head.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<script id="cookieyes" src=https://cdn-cookieyes.com/client_data/9c3338e8c0f82fb5466c9727/script.js></script>
<script>document.addEventListener("cookieyes_banner_load",()=>{let e=document.querySelector(".cky-consent-container");e&&e.setAttribute("data-nosnippet","true")});</script>
1 change: 1 addition & 0 deletions app/views/layouts/hyrax.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="<%= t("hyrax.document_language", default: '') %>" prefix="og:http://ogp.me/ns#">
<head>
<%= render '/cookie_consent/head' %>
<%= render partial: 'layouts/head_tag_content' %>
<%= content_for(:head) %>
</head>
Expand Down
1 change: 1 addition & 0 deletions app/views/shared/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
<li><a href="http://www.library.northwestern.edu/about/contact/general-feedback.html">Provide Feedback</a></li>
</ul>
</div>
<%= render '/cookie_consent/content' %>
</div>
</footer>
111 changes: 59 additions & 52 deletions terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 51 additions & 3 deletions terraform/ecs_services.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module "db_schema" {

module "arch_task_webapp" {
source = "./modules/arch_task"
db_pool_size = 5
container_config = local.container_config
cpu = 2048
memory = 4096
Expand Down Expand Up @@ -81,9 +82,9 @@ resource "aws_ecs_service" "arch_webapp" {
module "arch_task_worker" {
source = "./modules/arch_task"
container_config = local.container_config
cpu = 2048
db_pool_size = 20
memory = 4096
cpu = 4096
memory = 8192
db_pool_size = 50
container_role = "worker"
role_arn = aws_iam_role.arch_role.arn
app_name = var.app_name
Expand Down Expand Up @@ -117,3 +118,50 @@ resource "aws_ecs_service" "arch_worker" {

tags = local.tags
}

resource "aws_appautoscaling_target" "webapp_target" {
count = var.enable_autoscaling ? 1 : 0
max_capacity = var.service_count_max
min_capacity = var.service_count_min
resource_id = "service/${aws_ecs_cluster.arch.name}/${aws_ecs_service.arch_webapp.name}"
scalable_dimension = "ecs:service:DesiredCount"
service_namespace = "ecs"
}

resource "aws_appautoscaling_policy" "webapp_cpu_policy" {
count = var.enable_autoscaling ? 1 : 0
name = "scale-up-on-cpu"
policy_type = "TargetTrackingScaling"
resource_id = aws_appautoscaling_target.webapp_target[0].resource_id
scalable_dimension = aws_appautoscaling_target.webapp_target[0].scalable_dimension
service_namespace = aws_appautoscaling_target.webapp_target[0].service_namespace

target_tracking_scaling_policy_configuration {
predefined_metric_specification {
predefined_metric_type = "ECSServiceAverageCPUUtilization"
}
scale_in_cooldown = 300
scale_out_cooldown = 300

target_value = var.cpu_target
}
}

resource "aws_appautoscaling_policy" "webapp_memory_policy" {
count = var.enable_autoscaling ? 1 : 0
name = "auto-scale-on-mem"
policy_type = "TargetTrackingScaling"
resource_id = aws_appautoscaling_target.webapp_target[0].resource_id
scalable_dimension = aws_appautoscaling_target.webapp_target[0].scalable_dimension
service_namespace = aws_appautoscaling_target.webapp_target[0].service_namespace

target_tracking_scaling_policy_configuration {
predefined_metric_specification {
predefined_metric_type = "ECSServiceAverageMemoryUtilization"
}
scale_in_cooldown = 300
scale_out_cooldown = 300

target_value = var.cpu_target
}
}
30 changes: 30 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,33 @@ variable "recaptcha_secret_key" {
variable "recaptcha_site_key" {
type = string
}

variable "enable_autoscaling" {
type = bool
default = false
}

variable "service_count_min" {
type = number
default = 1
}

variable "service_count_max" {
type = number
default = 3
}

variable "service_count_desired" {
type = number
default = 1
}

variable "cpu_target" {
type = number
default = 70
}

variable "memory_target" {
type = number
default = 70
}
Loading