Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
e42c16e3
Commit
e42c16e3
authored
Nov 14, 2017
by
sim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly handle dev and prod environment
parent
1398ee26
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
29 deletions
+54
-29
INSTALL.md
INSTALL.md
+12
-3
Makefile
Makefile
+12
-9
mkconf.sh
tools/mkconf.sh
+30
-17
No files found.
INSTALL.md
View file @
e42c16e3
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
You need
`pipenv`
and an up-to-date version of
`pip`
. To setup development
You need
`pipenv`
and an up-to-date version of
`pip`
. To setup development
environment and run test server:
environment and run test server:
$ make
dev
$ make
$ pipenv run ./manage runserver
$ pipenv run ./manage runserver
...
@@ -46,10 +46,19 @@ If you use `pipenv shell`, don't forget to leave the virtualenv (`exit` or
...
@@ -46,10 +46,19 @@ If you use `pipenv shell`, don't forget to leave the virtualenv (`exit` or
To bootstrap Gargantext environment just cd into your local Gargantext repo and
To bootstrap Gargantext environment just cd into your local Gargantext repo and
do:
do:
$ make dev
$ make
Or for production (without dev dependencies and without DEBUG mode):
$ make TARGET=prod
To specify a path for configuration file (by default gargantext.ini in current
directory), use GARGANTEXT_CONF environment variable. For example:
$ GARGANTEXT_CONF=/etc/gargantext/gargantext.ini make TARGET=prod
If everything is going well, you now have a clean virtualenv with every
If everything is going well, you now have a clean virtualenv with every
packages you need to run Gargantext.
packages you need to run Gargantext
, and a fresh configuration file
.
You can now run any command by prefixing it with
`pipenv run`
or by first
You can now run any command by prefixing it with
`pipenv run`
or by first
entering the virtualenv with
`pipenv shell`
. To run Gargantext django backend
entering the virtualenv with
`pipenv shell`
. To run Gargantext django backend
...
...
Makefile
View file @
e42c16e3
.PHONY
:
dev prod
env conf
.PHONY
:
gargantext
env conf
dev
:
conf env
ifeq
($(TARGET),
"prod"
)
@
echo
"• Installing dependencies..."
TARG
=
prod
pipenv
install
--dev
PIPENV_ARGS
=
@
echo
else
TARG
=
dev
PIPENV_ARGS
=
--dev
endif
prod
:
conf env
gargantext
:
conf env
@
echo
"• Installing dependencies..."
@
echo
"• Installing dependencies..."
pipenv
install
pipenv
install
$(PIPENV_ARGS)
@
echo
@
echo
env
:
env
:
@
echo
"• Setup django settings module..."
@
echo
"• Setup django settings module
and configuration path
..."
./tools/mkenv.sh
./tools/mkenv.sh
@
echo
@
echo
conf
:
conf
:
@
echo
"• Setup gargantext configuration..."
@
echo
"• Setup gargantext configuration..."
./tools/mkconf.sh
./tools/mkconf.sh
$(TARG)
@
echo
@
echo
tools/mkconf.sh
View file @
e42c16e3
#!/usr/bin/env bash
#!/usr/bin/env bash
# Handle arguments
# Handle arguments
while
getopts
f option
;
do
while
:
;
do
case
"
${
option
}
"
case
$1
in
in
-h
|
--help
)
echo
"Usage:
$0
[-h|--help] [-f|--force] [dev|prod]"
;
exit
;;
f
)
FORCE
=
1
;;
-f
|
--force
)
FORCE
=
1
;;
--
)
shift
;
break
;;
*
)
break
esac
esac
shift
done
done
# Gargantext configuration file
# Target can be dev or prod
TARGET
=
"
${
1
:-
dev
}
"
# Gargantext configuration file path
[
-z
"
$GARGANTEXT_CONF
"
]
&&
GARGANTEXT_CONF
=
gargantext.ini
[
-z
"
$GARGANTEXT_CONF
"
]
&&
GARGANTEXT_CONF
=
gargantext.ini
# Configuration template
# Configuration template
path
TEMPLATE
=
tools/gargantext.template.ini
TEMPLATE
=
tools/gargantext.template.ini
# Check for configuration file existence
if
[
-f
"
$GARGANTEXT_CONF
"
-a
-z
"
$FORCE
"
]
;
then
if
[
-f
"
$GARGANTEXT_CONF
"
-a
-z
"
$FORCE
"
]
;
then
echo
"Configuration file
$GARGANTEXT_CONF
already exists. To generate a"
\
echo
-e
"Configuration file
$GARGANTEXT_CONF
already exists, you may"
\
"new configuration anyway you can do: ./tools/mkconf.sh -f"
"need to edit it.
\n
To generate a new configuration anyway you"
\
"can do: ./tools/mkconf.sh -f"
exit
exit
fi
fi
# Check permissions for configuration file
D
=
$(
dirname
$GARGANTEXT_CONF
)
D
=
$(
dirname
$GARGANTEXT_CONF
)
if
!
(
mkdir
-p
$D
&&
touch
$GARGANTEXT_CONF
2>/dev/null
)
;
then
if
!
(
mkdir
-p
$D
&&
touch
$GARGANTEXT_CONF
2>/dev/null
)
;
then
echo
"Can't create
$GARGANTEXT_CONF
, please check permissions."
echo
"Can't create
$GARGANTEXT_CONF
, please check permissions."
exit
1
exit
1
fi
fi
# Setup DEBUG mode for dev target
[
"
$TARGET
"
=
"prod"
]
&&
DEBUG
=
False
||
DEBUG
=
True
echo
"Generate secret key for Django..."
echo
"Generate secret key for Django..."
SECRET_KEY
=
$(
python ./tools/gensecret.py
)
SECRET_KEY
=
$(
python ./tools/gensecret.py
)
echo
"PostgreSQL configuration..."
echo
"PostgreSQL configuration..."
DB_NAME_DEFAULT
=
gargandb
DB_NAME_DEFAULT
=
gargandb
DB_USER_DEFAULT
=
gargantua
DB_USER_DEFAULT
=
gargantua
read
-p
"Database name [
$DB_NAME_DEFAULT
]: "
DB_NAME
read
-p
"Database name [
$DB_NAME_DEFAULT
]: "
DB_NAME
DB_NAME
=
${
DB_NAME
:-
$DB_NAME_DEFAULT
}
DB_NAME
=
${
DB_NAME
:-
$DB_NAME_DEFAULT
}
read
-p
"Database user [
$DB_USER_DEFAULT
]: "
DB_USER
read
-p
"Database user [
$DB_USER_DEFAULT
]: "
DB_USER
DB_USER
=
${
DB_USER
:-
$DB_USER_DEFAULT
}
DB_USER
=
${
DB_USER
:-
$DB_USER_DEFAULT
}
read
-s
-p
"Please provide the password for
$DB_USER
: "
DB_PASS
&&
echo
read
-s
-p
"Please provide the password for
$DB_USER
: "
DB_PASS
&&
echo
# Escape variables
# Escape variables
SECRET_KEY
=
$(
echo
-n
"
$SECRET_KEY
"
|
sed
-e
's/[\/&\"]/\\&/g'
)
SECRET_KEY
=
$(
echo
-n
"
$SECRET_KEY
"
|
sed
-e
's/[\/&\"]/\\&/g'
)
...
@@ -49,13 +61,14 @@ DB_USER=$(echo -n "$DB_USER" | sed -e 's/[\/&\"]/\\&/g')
...
@@ -49,13 +61,14 @@ DB_USER=$(echo -n "$DB_USER" | sed -e 's/[\/&\"]/\\&/g')
DB_PASS
=
$(
echo
-n
"
$DB_PASS
"
|
sed
-e
's/[\/&\"]/\\&/g'
)
DB_PASS
=
$(
echo
-n
"
$DB_PASS
"
|
sed
-e
's/[\/&\"]/\\&/g'
)
echo
"Generate configuration file from
$TEMPLATE
..."
echo
"Generate configuration file from
$TEMPLATE
..."
sed
-E
-e
's/[{]DEBUG[}]/True/g'
\
sed
-E
-e
"s/[{]DEBUG[}]/
$DEBUG
/g"
\
-e
"s/[{]SECRET_KEY[}]/
$SECRET_KEY
/g"
\
-e
"s/[{]SECRET_KEY[}]/
$SECRET_KEY
/g"
\
-e
"s/[{]DB_NAME[}]/
$DB_NAME
/g"
\
-e
"s/[{]DB_NAME[}]/
$DB_NAME
/g"
\
-e
"s/[{]DB_USER[}]/
$DB_USER
/g"
\
-e
"s/[{]DB_USER[}]/
$DB_USER
/g"
\
-e
"s/[{]DB_PASS[}]/
$DB_PASS
/g"
\
-e
"s/[{]DB_PASS[}]/
$DB_PASS
/g"
\
"
$TEMPLATE
"
>
"
$GARGANTEXT_CONF
"
\
"
$TEMPLATE
"
>
"
$GARGANTEXT_CONF
"
\
&&
echo
"Configuration written successfully in
$GARGANTEXT_CONF
."
&&
echo
"Configuration for
$TARGET
environment written successfully in"
\
"
$GARGANTEXT_CONF
."
[
-z
"
$DB_PASS
"
]
&&
echo
"You didn't provide any database password, please"
\
[
-z
"
$DB_PASS
"
]
&&
echo
"You didn't provide any database password, please"
\
"edit
$GARGANTEXT_CONF
before running Gargantext."
"edit
$GARGANTEXT_CONF
before running Gargantext."
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment