Skip to content

Commit

Permalink
Merge pull request #1050 from 18F/develop
Browse files Browse the repository at this point in the history
Fix for nginx buildpack and other issues
  • Loading branch information
XavierMetichecchia authored Oct 2, 2023
2 parents 32b8487 + 2c000c5 commit 8ff67f2
Show file tree
Hide file tree
Showing 13 changed files with 275 additions and 85 deletions.
2 changes: 0 additions & 2 deletions .cfignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ Guardfile
/node_modules
Dockerfile
Dockerfile.production

nginx.conf
138 changes: 125 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,158 @@
version: 2
version: 2.1
jobs:
build:
stage_deploy:
docker:
- image: cimg/ruby:2.7.8-browsers
steps:
- image: cimg/ruby:3.1.4-browsers
steps:
- checkout

- run:
name: Replace Data URL in _config.yml file when deploying to staging
command: |
sed -i 's@url: https://analytics\.usa\.gov@url: https://analytics-staging.app.cloud.gov@g' _config.yml
sed -i 's@ - name: analytics@ - name: analytics-staging@g' manifest.yml
sed -i 's@- analytics-s3@- analytics-s3-dev@g' manifest.yml
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
- v1-dependencies-

- run:
name: install dependencies
command: bundle install --jobs=4 --retry=3 && bundle config set --local path 'vendor/bundle'

- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}

- run:
name: install npm dependencies
command: |
npm install
sudo npm install -g eslint
sudo npm install -g webpack
sudo npm install -g envsub
- run:
name: lint javascript
command: npm run lint

- run:
name: run tests
command: npm run test

- run:
name: bundle for production javascript
command: npm run build-prod

- run:
name: install gems
command: bundle install

- run:
name: build site
command: bundle exec jekyll build

- run:
name: Run Envsubst on nginx.conf
command: envsubst '${S3_BUCKET_URL}' < nginx.conf.src > nginx.conf && pwd && cat nginx.conf

- run:
name: Install CF CLI
command: |
sudo wget --user-agent "Mozilla" -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - && sudo echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list && sudo apt-get update && sudo apt-get -y install cf8-cli curl
- run:
name: deploy
command: |
set -e
# Log into cloud.gov
cf api api.fr.cloud.gov
cf login -u $CF_USERNAME -p $CF_PASSWORD -o gsa-opp-analytics -s analytics-dev
cf push -f "./manifest.yml"
cf logout
main_deploy:
docker:
- image: cimg/ruby:3.1.4-browsers
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
- v1-dependencies-

- run:
name: install dependencies
command: bundle install --jobs=4 --retry=3 --path vendor/bundle
command: bundle install --jobs=4 --retry=3 && bundle config set --local path 'vendor/bundle'

- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}

- run:
name: install npm dependencies
command: |
npm install
sudo npm install -g eslint
sudo npm install -g webpack
sudo npm install -g envsub
- run:
name: lint javascript
command: npm run lint

- run:
name: run tests
command: npm run test

- run:
name: bundle for production javascript
command: npm run build-prod

- run:
name: install gems
command: bundle install

- run:
name: build site
command: bundle exec jekyll build
# Install Cloud Foundry cli (cf) before deploy step. cf is used to push to Cloud.gov
command: bundle exec jekyll build

- run:
name: install-cf-cli
name: Run Envsubst on nginx.conf
command: envsubst '${S3_BUCKET_URL}' < nginx.conf.src > nginx.conf && pwd && cat nginx.conf

- run:
name: Install CF CLI
command: |
curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&source=github'
sudo dpkg -i cf-cli_amd64.deb
cf -v
sudo wget --user-agent "Mozilla" -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - && sudo echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list && sudo apt-get update && sudo apt-get -y install cf8-cli curl
- run:
name: deploy develop and master branches to cloud.gov
command: bin/deploy-ci.sh
name: deploy
command: |
set -e
# Log into cloud.gov
cf api api.fr.cloud.gov
cf login -u $CF_USERNAME -p $CF_PASSWORD -o gsa-opp-analytics -s analytics-dev
cf push -f "./manifest.yml"
cf logout
workflows:
stage_workflow:
jobs:
- stage_deploy:
filters:
branches:
only:
- develop

main_workflow:
jobs:
- main_deploy:
filters:
branches:
only:
- master
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ _site
/node_modules
Dockerfile
Dockerfile.production
/check
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
source "https://rubygems.org"

ruby '2.7.8'
ruby '3.1.4'

gem 'jekyll', '~> 3.9.0'
gem 'jekyll', '~> 4.3.2'
gem 'bourbon', '~> 4.3.4'
gem 'kramdown-parser-gfm'
gem 'sass', '~> 3.4.24'
gem 'neat', '~> 2.1.0'
gem "webrick", "~> 1.8"

group :jekyll_plugins do
gem 'jekyll-datapage-generator'
gem 'jekyll-redirect-from'
gem 'jekyll-sitemap'
end
end
45 changes: 28 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.4)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
bourbon (4.3.4)
sass (~> 3.4)
Expand All @@ -14,27 +14,31 @@ GEM
eventmachine (1.2.7)
ffi (1.15.5)
forwardable-extended (2.6.0)
google-protobuf (3.24.3-x86_64-darwin)
http_parser.rb (0.8.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
jekyll (3.9.3)
jekyll (4.3.2)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
i18n (>= 0.7, < 2)
jekyll-sass-converter (~> 1.0)
i18n (~> 1.0)
jekyll-sass-converter (>= 2.0, < 4.0)
jekyll-watch (~> 2.0)
kramdown (>= 1.17, < 3)
kramdown (~> 2.3, >= 2.3.1)
kramdown-parser-gfm (~> 1.0)
liquid (~> 4.0)
mercenary (~> 0.3.3)
mercenary (>= 0.3.6, < 0.5)
pathutil (~> 0.9)
rouge (>= 1.7, < 4)
rouge (>= 3.0, < 5.0)
safe_yaml (~> 1.0)
terminal-table (>= 1.8, < 4.0)
webrick (~> 1.7)
jekyll-datapage-generator (1.4.0)
jekyll-redirect-from (0.16.0)
jekyll (>= 3.3, < 5.0)
jekyll-sass-converter (1.5.2)
sass (~> 3.4)
jekyll-sass-converter (3.0.0)
sass-embedded (~> 1.54)
jekyll-sitemap (1.4.0)
jekyll (>= 3.7, < 5.0)
jekyll-watch (2.2.1)
Expand All @@ -47,37 +51,44 @@ GEM
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.3.6)
mercenary (0.4.0)
neat (2.1.0)
sass (~> 3.4)
thor (~> 0.19)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (5.0.1)
public_suffix (5.0.3)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.5)
rouge (3.30.0)
rexml (3.2.6)
rouge (4.1.3)
safe_yaml (1.0.5)
sass (3.4.25)
sass-embedded (1.68.0-x86_64-darwin)
google-protobuf (~> 3.23)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (0.20.3)
unicode-display_width (2.4.2)
webrick (1.8.1)

PLATFORMS
ruby
x86_64-darwin-21

DEPENDENCIES
bourbon (~> 4.3.4)
jekyll (~> 3.9.0)
jekyll (~> 4.3.2)
jekyll-datapage-generator
jekyll-redirect-from
jekyll-sitemap
kramdown-parser-gfm
neat (~> 2.1.0)
sass (~> 3.4.24)
webrick (~> 1.8)

RUBY VERSION
ruby 2.7.8p225
ruby 3.1.4p223

BUNDLED WITH
2.1.4
2.4.19
1 change: 0 additions & 1 deletion Staticfile

This file was deleted.

4 changes: 4 additions & 0 deletions apt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
packages:
- inotify-tools
- gettext-base
23 changes: 0 additions & 23 deletions bin/deploy-ci.sh

This file was deleted.

Empty file added conf.d/default.conf
Empty file.
2 changes: 2 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
nginx -p $PWD -c nginx.conf
20 changes: 10 additions & 10 deletions manifest.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
applications:
- name: analytics
instances: 2
memory: 128M
buildpack: staticfile_buildpack
stack: cflinuxfs4
- name: analytics-staging
instances: 1
memory: 128M
buildpack: staticfile_buildpack
stack: cflinuxfs4
- name: analytics
instances: 1
memory: 128M
buildpacks:
- https://github.com/cloudfoundry/apt-buildpack
- nginx_buildpack
stack: cflinuxfs4
services:
- analytics-s3
command: "chmod +x ./entrypoint.sh && ./entrypoint.sh"
Loading

0 comments on commit 8ff67f2

Please sign in to comment.