Skip to content

Commit

Permalink
Update development and build environment.
Browse files Browse the repository at this point in the history
- Upgrade Ruby environment to supported version of Ruby (v2.7 to v3.3).
- Upgrade Node environment to supported version of NodeJS (v14 to v20).
- Update GitHub Actions to supported versions of actions.
- Fix Docker environment to work with NREL's network SSL setup and
  provide new instructions for that setup.
- Switch from yarn to pnpm for npm dependencies.
- Update gem and npm dependencies (mostly just latest patch/minor
  versions).
  • Loading branch information
GUI committed Aug 21, 2024
1 parent 508643f commit 892ef1f
Show file tree
Hide file tree
Showing 17 changed files with 7,735 additions and 6,418 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,28 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7"
ruby-version: "3.3"
bundler-cache: true

- uses: actions/setup-node@v2
- uses: pnpm/action-setup@v4
with:
node-version: "14"
cache: yarn
cache-dependency-path: "**/yarn.lock"
version: 8

# Yarn dependencies
- name: Yarn Install
run: yarn install
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: pnmp
cache-dependency-path: "**/pnpm-lock.yaml"

# NPM dependencies
- name: pnpm Install
run: pnpm install

# Build
- name: Set production DEPLOY_ENV
Expand All @@ -42,7 +46,7 @@ jobs:
run: bundle exec rake lint

# Artifact
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v4
if: success() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
with:
name: build
Expand All @@ -64,7 +68,7 @@ jobs:
image: rclone/rclone:1.57.0
steps:
# Deploy to S3 bucket.
- uses: actions/download-artifact@v1
- uses: actions/download-artifact@v4
with:
name: build
path: ./build
Expand Down
69 changes: 45 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,59 @@
FROM ruby:2.7-bullseye
FROM public.ecr.aws/docker/library/ruby:3.3-bookworm

ENV \
BUNDLE_JOBS=4 \
BUNDLE_RETRY=3 \
BUNDLE_JOBS=20 \
BUNDLE_RETRY=5 \
DOCKER=true \
NODE_OPTIONS=--use-openssl-ca \
NODE_MODULES_DIR=/usr/local/node_modules
NODE_MODULES_DIR=/usr/local/node_modules \
NODE_OPTIONS="--use-openssl-ca --openssl-shared-config" \
PNPM_HOME=/usr/local/pnpm

# Determine Debian version
RUN apt-get update && apt-get -y install lsb-release

# NodeJS and Yarn
# Install NREL root certs for machines running on NREL's network.
ARG NREL_ROOT_CERT_URL_ROOT=""
RUN set -x && \
if [ -n "$NREL_ROOT_CERT_URL_ROOT" ]; then \
curl -fsSLk -o /usr/local/share/ca-certificates/nrel_root.crt "${NREL_ROOT_CERT_URL_ROOT}/nrel_root.pem" && \
curl -fsSLk -o /usr/local/share/ca-certificates/nrel_xca1.crt "${NREL_ROOT_CERT_URL_ROOT}/nrel_xca1.pem" && \
update-ca-certificates; \
fi

# NodeJS and pnpm
ARG NODEJS_MAJOR_VERSION=20
ARG PNPM_VERSION=8.15.9
RUN set -x && \
VERSION=node_14.x && \
DISTRO="$(lsb_release -s -c)" && \
curl -sSk https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
echo "deb http://deb.nodesource.com/$VERSION $DISTRO main" > /etc/apt/sources.list.d/nodesource.list && \
echo "deb-src http://deb.nodesource.com/$VERSION $DISTRO main" >> /etc/apt/sources.list.d/nodesource.list && \
curl -sSk https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb http://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
version="node_${NODEJS_MAJOR_VERSION}.x" && \
distro=$(. /etc/os-release && echo "$VERSION_CODENAME") && \
apt-get update && \
apt-get -y install nodejs yarn
ENV NODE_OPTIONS --use-openssl-ca
curl -fsSL -o /usr/share/keyrings/nodesource.asc https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key && \
echo "deb [signed-by=/usr/share/keyrings/nodesource.asc] https://deb.nodesource.com/$version nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get -y --no-install-recommends install nodejs && \
npm install -g "pnpm@${PNPM_VERSION}" && \
npmrc_path="$(npm config get globalconfig)" && \
if [ "$npmrc_path" != "/etc/npmrc" ]; then \
mkdir -p "$(dirname $npmrc_path)" && \
ln -s "$npmrc_path" /etc/npmrc; \
fi && \
echo "update-notifier=false" > /etc/npmrc && \
echo "cafile=/etc/ssl/certs/ca-certificates.crt" >> /etc/npmrc && \
echo "store-dir=${PNPM_HOME}/store" >> /etc/npmrc && \
mkdir -p "${NODE_MODULES_DIR}/.pnpm" && \
rm -rf /var/lib/apt/lists/* /var/lib/dpkg/*-old /var/cache/* /var/log/* /root/.npm

RUN mkdir -p /app
WORKDIR /app

# Install gems (all gems first for better Docker caching for CI/CD).
COPY Gemfile Gemfile.lock /app/
RUN bundle install --jobs=20 --retry=5

COPY package.json yarn.lock /app/
RUN mkdir -p "$NODE_MODULES_DIR" && \
ln -s "$NODE_MODULES_DIR" /app/node_modules && \
yarn
RUN bundle install
ARG BUNDLE_INSTALL_ARGS="--frozen --without=development test"
RUN set -x && bundle install $BUNDLE_INSTALL_ARGS && bundle clean --force --verbose

# Install NPM dependencies.
COPY package.json pnpm-lock.yaml /app/
ARG PNPM_INSTALL_ARGS="--frozen-lockfile"
RUN --mount=type=cache,target=/usr/local/pnpm/store set -x && \
pnpm install $PNPM_INSTALL_ARGS

COPY . /app

Expand Down
8 changes: 5 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
source "https://rubygems.org"

ruby "~> 3.3.0"

# Middleman Gems
gem "middleman", "~> 4.4.2"
gem "middleman", "~> 4.5.1"
gem "middleman-livereload", "~> 3.4.6"

# GitHub-flavored markdown.
gem "kramdown-parser-gfm", "~> 1.1.0"

# Environment specific config with environment variables
gem "dotenv", "~> 2.7.2"
gem "dotenv", "~> 3.1.2"

# Syntax highlighting
gem "middleman-syntax", "~> 3.2.0"
gem "middleman-syntax", "~> 3.4.0"

# Redirects
gem "middleman-alias", "~> 0.0.17"
Expand Down
116 changes: 60 additions & 56 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,69 +1,70 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (6.1.7.6)
activesupport (7.0.8.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
backports (3.21.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
backports (3.25.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.2.2)
contracts (0.13.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.6)
concurrent-ruby (1.3.4)
contracts (0.16.1)
domain_name (0.6.20240107)
dotenv (3.1.2)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
erubis (2.7.0)
eventmachine (1.2.7)
execjs (2.8.1)
execjs (2.9.1)
fast_blank (1.0.1)
fastimage (2.2.6)
ffi (1.15.4)
haml (5.2.2)
temple (>= 0.8.0)
fastimage (2.3.1)
ffi (1.17.0)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-x86_64-linux-gnu)
haml (6.3.0)
temple (>= 0.8.2)
thor
tilt
hamster (3.0.0)
concurrent-ruby (~> 1.0)
hashie (3.6.0)
http-accept (1.7.0)
http-cookie (1.0.4)
http-cookie (1.0.7)
domain_name (~> 0.5)
http_parser.rb (0.8.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
kramdown (2.3.1)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
memoist (0.16.2)
middleman (4.4.2)
middleman (4.5.1)
coffee-script (~> 2.2)
haml (>= 4.0.5)
kramdown (>= 2.3.0)
middleman-cli (= 4.4.2)
middleman-core (= 4.4.2)
middleman-cli (= 4.5.1)
middleman-core (= 4.5.1)
middleman-alias (0.0.17)
middleman-core (>= 3.3)
middleman-cli (4.4.2)
thor (>= 0.17.0, < 2.0)
middleman-core (4.4.2)
activesupport (>= 6.1, < 7.0)
middleman-cli (4.5.1)
thor (>= 0.17.0, < 1.3.0)
middleman-core (4.5.1)
activesupport (>= 6.1, < 7.1)
addressable (~> 2.4)
backports (~> 3.6)
bundler (~> 2.0)
contracts (~> 0.13.0)
contracts (~> 0.13, < 0.17)
dotenv
erubis
execjs (~> 2.0)
Expand All @@ -72,7 +73,7 @@ GEM
hamster (~> 3.0)
hashie (~> 3.4)
i18n (~> 1.6.0)
listen (~> 3.0.0)
listen (~> 3.0)
memoist (~> 0.14)
padrino-helpers (~> 0.15.0)
parallel
Expand All @@ -87,68 +88,71 @@ GEM
em-websocket (~> 0.5.1)
middleman-core (>= 3.3)
rack-livereload (~> 0.3.15)
middleman-syntax (3.2.0)
middleman-syntax (3.4.0)
middleman-core (>= 3.2)
rouge (~> 3.2)
mime-types (3.4.1)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.1115)
minitest (5.19.0)
mime-types-data (3.2024.0820)
minitest (5.25.1)
multi_json (1.15.0)
netrc (0.11.0)
padrino-helpers (0.15.1)
padrino-helpers (0.15.3)
i18n (>= 0.6.7, < 2)
padrino-support (= 0.15.1)
padrino-support (= 0.15.3)
tilt (>= 1.4.1, < 3)
padrino-support (0.15.1)
parallel (1.21.0)
padrino-support (0.15.3)
parallel (1.26.3)
parslet (2.0.0)
public_suffix (4.0.6)
rack (2.2.6.4)
public_suffix (6.0.1)
rack (2.2.9)
rack-livereload (0.3.17)
rack
rake (13.0.6)
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.5)
rouge (3.27.0)
rexml (3.3.5)
strscan
rouge (3.30.0)
sassc (2.4.0)
ffi (~> 1.9)
servolux (0.13.0)
temple (0.8.2)
thor (1.1.0)
tilt (2.0.10)
strscan (3.1.0)
temple (0.10.3)
thor (1.2.2)
tilt (2.0.11)
toml (0.3.0)
parslet (>= 1.8.0, < 3.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.8)
webrick (1.7.0)
zeitwerk (2.6.11)
webrick (1.8.1)

PLATFORMS
aarch64-linux
ruby
x86_64-linux

DEPENDENCIES
dotenv (~> 2.7.2)
dotenv (~> 3.1.2)
kramdown-parser-gfm (~> 1.1.0)
middleman (~> 4.4.2)
middleman (~> 4.5.1)
middleman-alias (~> 0.0.17)
middleman-livereload (~> 3.4.6)
middleman-syntax (~> 3.2.0)
middleman-syntax (~> 3.4.0)
multi_json (~> 1.15.0)
rake (~> 13.0)
rest-client (~> 2.1.0)

RUBY VERSION
ruby 3.3.4p94

BUNDLED WITH
2.1.4
2.5.11
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@ This repository stores the website content and documentation for [developer.nrel

The content files to edit are in [`./source`](https://github.com/NREL/developer.nrel.gov/tree/master/source). To preview your changes you can use the [Middleman](https://middlemanapp.com) preview server. To run Middleman:

1. Install [Docker](https://www.docker.com/community-edition) on your computer.
1. Install [Docker](https://www.docker.com/products/docker-desktop/) on your computer.
2. Checkout the `developer.nrel.gov` repository on your computer (`git clone https://github.com/NREL/developer.nrel.gov.git`).
3. Inside the `developer.nrel.gov` directory, run `docker-compose up`.
4. View your changes at: http://localhost:4480/
3. For NREL employees on the NREL network: Add a `docker-compose.override.yml`, with the following contents, but substituting `REPLACE_ME` with the appropriate URL (reach out to a maintainer for this value):

```yaml
services:
web:
build:
args:
NREL_ROOT_CERT_URL_ROOT: "REPLACE_ME"
```
4. Inside the `developer.nrel.gov` directory, run `docker compose up`.
5. View your changes at: http://localhost:4480/

### Linting

Expand Down
2 changes: 1 addition & 1 deletion bin/docker-compose/bundle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
exec docker-compose run --rm web "$(basename "$0")" "$@"
exec docker compose run --rm web "$(basename "$0")" "$@"
Loading

0 comments on commit 892ef1f

Please sign in to comment.