Skip to content
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

Initial Artifactory Pro plan #856

Merged
merged 1 commit into from
Jun 15, 2016
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
14 changes: 14 additions & 0 deletions plans/artifactory-pro/config/storage.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type={{cfg.database.type}}
url={{cfg.database.url}}
driver={{cfg.database.driver}}

## Determines where the actual artifacts binaries are stored. Available options:
## filesystem - binaries are stored in the filesystem (recommended, default)
## fullDb - binaries are stored as blobs in the db, filesystem is used for caching
## cachedFS - binaries are stored in the filesystem, but a front cache (with faster access) is added
## IMPORTANT NOTE: This property should not be change after the initial setup. To change binaries storage you have to export and import
binary.provider.type={{cfg.storage.binary_provider_type}}

## Determines the maximum filesystem cache size in bytes when using binary provider type fullDb or cachedFS. Default is 5GB
## Supported units are TB (terabytes), GB (gigabytes), MB (megabytes) and KB (kilobytes)
binary.provider.cache.maxSize={{cfg.storage.binary_provider_cache_size}}
21 changes: 21 additions & 0 deletions plans/artifactory-pro/default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# _ _ __ _ _____
# /\ | | (_)/ _| | | | __ \
# / \ _ __| |_ _| |_ __ _ ___| |_ ___ _ __ _ _ | |__) | __ ___
# / /\ \ | '__| __| | _/ _` |/ __| __/ _ \| '__| | | | | ___/ '__/ _ \
# / ____ \| | | |_| | || (_| | (__| || (_) | | | |_| | | | | | | (_) |
# /_/ \_\_| \__|_|_| \__,_|\___|\__\___/|_| \__, | |_| |_| \___/
# __/ |
# |___/

license = ""

[database]

type = "derby"
url = "jdbc:derby:{db.home};create=true"
driver = "org.apache.derby.jdbc.EmbeddedDriver"

[storage]

binary_provider_type = "filesystem"
binary_provider_cache_size = "5GB"
27 changes: 27 additions & 0 deletions plans/artifactory-pro/hooks/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

echo "Preparing ARTIFACTORY_HOME..."

# Move directories that ship in the package into place
for dir in bin etc tomcat webapps
do
cp -R {{pkg.path}}/$dir {{pkg.svc_var_path}}/
done

# Create required ephemeral directories
for dir in backup data logs
do
mkdir -p {{pkg.svc_var_path}}/$dir
done

# Set license data
echo {{cfg.license}} > {{pkg.svc_var_path}}/etc/artifactory.lic

# Symlink config files into $ARTIFACTORY_HOME/etc
for config in storage.properties
do
echo "Linking $config"
ln -sf {{pkg.svc_config_path}}/$config {{pkg.svc_var_path}}/etc/$config
done

chown -R hab:hab {{pkg.svc_path}}/*
8 changes: 8 additions & 0 deletions plans/artifactory-pro/hooks/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

echo "Starting Artifactory Pro"

export JAVA_HOME=$(hab pkg path core/server-jre)
export ARTIFACTORY_HOME={{pkg.svc_var_path}}

{{pkg.svc_var_path}}/bin/artifactory.sh 2>&1
Copy link
Contributor

@kevindickerson kevindickerson Jun 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I saw @adamhjk switched the redis plan from using a run hook to a line in plan.sh:

pkg_svc_run="bin/redis-server $pkg_svc_config_path/redis.config"

Maybe that's cleaner than using a run hook? Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevindickerson I think we need the hook as those exported environment variables are required in order for artifactory.sh to operate correctly. JAVA_HOME needs to be dynamically resolved at hook execution time also.

Copy link
Contributor

@kevindickerson kevindickerson Jun 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So like

pkg_svc_run="JAVA_HOME=$(pkg_path_for core/server-jre) ARTIFACTORY_HOME=$pkg_svc_var_path $pkg_svc_var_path/bin/artifactory.sh 2>&1"

wouldn't work? (I think pkg_path_for should pull it at execute time??)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things begin to get pretty unreadable at some point. I would love to hear a comparison on using pkg_svc_run vs a run hook. @fnichol ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm honestly not sure which is better than the other. Certainly having a separate run hook is less long. :)

Copy link
Contributor

@kevindickerson kevindickerson Jun 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, also worth noting that pkg_svc_run should not fork! Also ends with 2>&1 by default

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say you should make a run hook if the thing gets longer that what should fit on one line, as a loose, subjective, guideline.

pkg_svc_run is nice for plans that don't have any other hooks because you only need to have the plan.sh file, but if you already have a hooks directory, and your run hook is more than one line, put it in a separate hook.

21 changes: 21 additions & 0 deletions plans/artifactory-pro/plan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pkg_origin=core
pkg_name=artifactory-pro
pkg_version=4.8.1
pkg_maintainer="The Habitat Maintainers <[email protected]>"
pkg_license=("JFrog Artifactory EULA")
pkg_source=https://dl.bintray.com/jfrog/${pkg_name}/org/artifactory/pro/jfrog-${pkg_name}/${pkg_version}/jfrog-${pkg_name}-${pkg_version}.zip
pkg_shasum=481f755a51faa33492829becb5f00ed3e07a392a0669a02d4d874db13dbcbc3f
pkg_deps=(core/bash core/server-jre)
pkg_build_deps=(core/unzip)
pkg_expose=(8081)

do_build() {
fix_interpreter "bin/artifactory.sh" core/bash bin/bash
return 0
}

do_install() {
build_line "Copying files from $PWD"
mkdir -p $pkg_prefix
cp -R * $pkg_prefix/
}