Skip to content

Commit

Permalink
Merge pull request #37 from cultuurnet/feature/III-6388
Browse files Browse the repository at this point in the history
Update build configuration for inclusion in UiTdatabank project
  • Loading branch information
willaerk authored Nov 4, 2024
2 parents 4740069 + 9193618 commit 080d024
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 75 deletions.
13 changes: 4 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const port = process.env.PORT || 4000;
const host = process.env.HOST || '127.0.0.1';
const express = require('express');
const app = express();
const logger = require('./utils/logger');
const scraper = require('./utils/scraper');
const findPublishers = require('./utils/findPublishers');
const handleArticle = require('./utils/handleArticle');

app.listen(port);
app.listen(port, host);

app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
Expand All @@ -23,10 +24,10 @@ app.post('/linkArticle', (req, res) => {

let url = req.body.url;
const cdbid = req.body.cdbid;

scraper(url, res)
.then( response => {
const meta = response; // get the metadata
const meta = response; // get the metadata
const foundPublishers = findPublishers(meta.url); // check if publisher is trusted
if(foundPublishers.length) {
// trusted publisher
Expand All @@ -45,9 +46,3 @@ app.post('/linkArticle', (req, res) => {
res.status(200).send(res.message);
});
});






4 changes: 4 additions & 0 deletions lib/tasks/build.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
desc "Build binaries"
task :build do |task|
system('npm install --production') or exit 1
end
34 changes: 34 additions & 0 deletions lib/tasks/build_artifact.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
desc "Create a debian package from the binaries."
task :build_artifact do |task|

calver_version = ENV['PIPELINE_VERSION'].nil? ? Time.now.strftime("%Y.%m.%d.%H%M%S") : ENV['PIPELINE_VERSION']
git_short_ref = `git rev-parse --short HEAD`.strip
version = ENV['ARTIFACT_VERSION'].nil? ? "#{calver_version}+sha.#{git_short_ref}" : ENV['ARTIFACT_VERSION']
artifact_name = 'uitdatabank-articlelinker'
vendor = 'publiq VZW'
maintainer = 'Infra publiq <[email protected]>'
license = 'Apache-2.0'
description = 'UiTdatabank Article Linker'
source = 'https://github.com/cultuurnet/uit-articlelinker'
build_url = ENV['JOB_DISPLAY_URL'].nil? ? "" : ENV['JOB_DISPLAY_URL']

FileUtils.mkdir_p('pkg')
FileUtils.mkdir_p('log')

system("fpm -s dir -t deb -n #{artifact_name} -v #{version} -a all -p pkg \
-x pkg -x vendor -x lib -x Rakefile -x Gemfile -x Gemfile.lock \
-x .bundle -x 'Jenkinsfile*' -x '.git*' -d nodejs \
--prefix /var/www/uitdatabank-articlelinker \
--config-files /var/www/uitdatabank-articlelinker/config.json \
--config-files /var/www/uitdatabank-articlelinker/publishers.json \
--deb-systemd lib/tasks/uitdatabank-articlelinker.service \
--before-remove lib/tasks/prerm \
--deb-user www-data --deb-group www-data \
--description '#{description}' --url '#{source}' --vendor '#{vendor}' \
--license '#{license}' -m '#{maintainer}' \
--deb-field 'Pipeline-Version: #{calver_version}' \
--deb-field 'Git-Ref: #{git_short_ref}' \
--deb-field 'Build-Url: #{build_url}' \
."
) or exit 1
end
6 changes: 0 additions & 6 deletions lib/tasks/curator-articlelinker/build.rake

This file was deleted.

37 changes: 0 additions & 37 deletions lib/tasks/curator-articlelinker/build_artifact.rake

This file was deleted.

3 changes: 0 additions & 3 deletions lib/tasks/curator-articlelinker/prerm

This file was deleted.

16 changes: 0 additions & 16 deletions lib/tasks/curator-articlelinker/upstart/curator-articlelinker

This file was deleted.

3 changes: 3 additions & 0 deletions lib/tasks/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

service uitdatabank-articlelinker stop || exit 0
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[Unit]
Description=Curator Articlelinker
Description=UiTdatabank Articlelinker
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
User=www-data
Group=www-data
PIDFile=/var/run/curator-articlelinker.pid
EnvironmentFile=-/etc/default/curator-articlelinker
WorkingDirectory=/var/www/curator-articlelinker
PIDFile=/var/run/uitdatabank-articlelinker.pid
EnvironmentFile=-/etc/default/uitdatabank-articlelinker
WorkingDirectory=/var/www/uitdatabank-articlelinker
ExecStart=/usr/bin/node index.js
Restart=on-failure
RestartSec=10s
Expand Down

0 comments on commit 080d024

Please sign in to comment.