Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Cozy Stack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
Cozy Stack
Commits
2934e508
Commit
2934e508
authored
8 years ago
by
Pierre Guilleminot
Browse files
Options
Downloads
Patches
Plain Diff
Simpler image docker with cozy-stack build outside of docker
parent
787c9e0a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
scripts/Dockerfile
+42
-49
42 additions, 49 deletions
scripts/Dockerfile
scripts/build.sh
+50
-18
50 additions, 18 deletions
scripts/build.sh
scripts/cozy-app-dev.sh
+20
-18
20 additions, 18 deletions
scripts/cozy-app-dev.sh
with
112 additions
and
85 deletions
scripts/Dockerfile
+
42
−
49
View file @
2934e508
...
@@ -4,31 +4,26 @@
...
@@ -4,31 +4,26 @@
FROM
debian:jessie
FROM
debian:jessie
# CouchDB and CGo dependencies
# CouchDB
ENV
COUCHDB_VERSION 2.0.0
ENV
COUCHDB_SRC_URL https://dist.apache.org/repos/dist/release/couchdb/source/$COUCHDB_VERSION/apache-couchdb-$COUCHDB_VERSION.tar.gz
ENV
COUCHDB_SRC_SHA256 ccaf3ce9cb06c50a73e091696e557e2a57c5ba02c5b299e1ac2f5b959ee96eca
RUN
apt-get update
&&
apt-get
install
-y
--no-install-recommends
\
RUN
apt-get update
&&
apt-get
install
-y
--no-install-recommends
\
bash
\
build-essential
\
git
\
ca-certificates
\
ca-certificates
\
curl
\
curl
\
libicu52
\
libicu52
\
libmozjs185-1.0
\
libmozjs185-1.0
\
erlang
\
erlang-nox
\
erlang-reltool
\
erlang-dev
\
libicu-dev
\
libicu-dev
\
libmozjs185-dev
\
libmozjs185-dev
\
openssl
\
openssl
\
g++
\
&&
rm
-rf
/var/lib/apt/lists/
*
\
gcc
\
&&
mkdir
/usr/src/couchdb
\
libc6-dev
\
make
\
pkg-config
\
&&
rm
-rf
/var/lib/apt/lists/
*
# CouchDB
ENV
COUCHDB_VERSION 2.0.0
ENV
COUCHDB_SRC_URL https://dist.apache.org/repos/dist/release/couchdb/source/$COUCHDB_VERSION/apache-couchdb-$COUCHDB_VERSION.tar.gz
ENV
COUCHDB_SRC_SHA256 ccaf3ce9cb06c50a73e091696e557e2a57c5ba02c5b299e1ac2f5b959ee96eca
RUN
mkdir
/usr/src/couchdb
\
&&
curl
-fsSL
"
$COUCHDB_SRC_URL
"
-o
couchdb.tar.gz
\
&&
curl
-fsSL
"
$COUCHDB_SRC_URL
"
-o
couchdb.tar.gz
\
&&
echo
"
$COUCHDB_SRC_SHA256
couchdb.tar.gz"
|
sha256sum
-c
-
\
&&
echo
"
$COUCHDB_SRC_SHA256
couchdb.tar.gz"
|
sha256sum
-c
-
\
&&
tar
-xzf
couchdb.tar.gz
-C
/usr/src/couchdb
--strip-components
=
1
\
&&
tar
-xzf
couchdb.tar.gz
-C
/usr/src/couchdb
--strip-components
=
1
\
...
@@ -37,43 +32,39 @@ RUN mkdir /usr/src/couchdb \
...
@@ -37,43 +32,39 @@ RUN mkdir /usr/src/couchdb \
&&
./configure
--disable-docs
\
&&
./configure
--disable-docs
\
&&
make release
\
&&
make release
\
&&
mv
./rel/couchdb /usr/local
\
&&
mv
./rel/couchdb /usr/local
\
&&
rm
-rf
/usr/src/couchdb
&&
rm
-rf
/usr/src/couchdb
\
ENV
PATH $PATH:/usr/local/couchdb/bin
# Cleanup
&& apt-get purge -y \
binutils \
# Golang
build-essential \
ENV
GOLANG_VERSION 1.7.4
cpp \
ENV
GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
ENV
GOLANG_DOWNLOAD_SHA256 47fda42e46b4c3ec93fa5d4d4cc6a748aa3f9411a2a2b7e08e3a6d80d753ec8b
RUN
curl
-fsSL
"
$GOLANG_DOWNLOAD_URL
"
-o
golang.tar.gz
\
&&
echo
"
$GOLANG_DOWNLOAD_SHA256
golang.tar.gz"
|
sha256sum
-c
-
\
&&
tar
-xzf
golang.tar.gz
-C
/usr/local
\
&&
rm
golang.tar.gz
ENV
GOPATH /go
ENV
PATH $GOPATH/bin:/usr/local/go/bin:$PATH
RUN
mkdir
-p
"
$GOPATH
/src"
"
$GOPATH
/bin"
&&
chmod
-R
777
"
$GOPATH
"
RUN
go get github.com/mholt/caddy/caddy
ENV
COZY_ENV development
RUN
go get
-d
github.com/cozy/cozy-stack
RUN
cd
"
$GOPATH
/src/github.com/cozy/cozy-stack"
\
&&
./scripts/build.sh
install
# Cleanup
RUN
apt-get purge
-y
\
erlang-dev \
erlang-dev \
libicu-dev \
libicu-dev \
libmozjs185-dev \
libmozjs185-dev \
&&
apt-get autoremove
-y
\
make \
&&
apt-get clean
perl \
&& echo "[chttpd]\nbind_address = 0.0.0.0" \
> /usr/local/couchdb/etc/local.ini \
&& apt-get autoremove -y && apt-get clean \
&& apt-get install -y libicu52 --no-install-recommends
ENV
PATH $PATH:/usr/local/couchdb/bin
# Caddy
ENV
CADDY_VERSION v0.9.5
ENV
CADDY_DOWNLOAD_URL https://github.com/mholt/caddy/releases/download/$CADDY_VERSION/caddy_linux_amd64.tar.gz
ENV
CADDY_DOWNLOAD_SHA256 c759640c9f56f7c4bb9fa828c0fa81a6e45f0f607e68677d56471bba53ad1777
RUN
curl
-fsSL
"
$CADDY_DOWNLOAD_URL
"
-o
caddy.tar.gz
\
&&
echo
"
$CADDY_DOWNLOAD_SHA256
caddy.tar.gz"
|
sha256sum
-c
-
\
&&
tar
-xz
-C
"
$GOPATH
/bin"
-f
caddy.tar.gz caddy_linux_amd64
\
&&
mv
$GOPATH
/bin/caddy_linux_amd64
$GOPATH
/bin/caddy
\
&&
rm
caddy.tar.gz
RUN
echo
"[chttpd]
\n
bind_address = 0.0.0.0"
\
>
/usr/local/couchdb/etc/local.ini
# cozy-stack
COPY
cozy-stack /usr/bin
RUN
chmod
+x /usr/bin/cozy-stack
COPY
cozy-app-dev.sh /usr/bin
COPY
cozy-app-dev.sh /usr/bin
RUN
chmod
+x /usr/bin/cozy-app-dev.sh
RUN
chmod
+x /usr/bin/cozy-app-dev.sh
...
@@ -81,6 +72,8 @@ ENV COZY_PROXY_HOST cozy.local
...
@@ -81,6 +72,8 @@ ENV COZY_PROXY_HOST cozy.local
ENV
COZY_PROXY_PORT 8080
ENV
COZY_PROXY_PORT 8080
ENV
COZY_STACK_HOST localhost
ENV
COZY_STACK_HOST localhost
ENV
COZY_STACK_PORT 8081
ENV
COZY_STACK_PORT 8081
ENV
COZY_PROXY_PATH caddy
ENV
COZY_STACK_PATH cozy-stack
RUN
mkdir
-p
/data/cozy-app
&&
mkdir
-p
/data/cozy-storage
RUN
mkdir
-p
/data/cozy-app
&&
mkdir
-p
/data/cozy-storage
...
...
This diff is collapsed.
Click to expand it.
scripts/build.sh
+
50
−
18
View file @
2934e508
...
@@ -22,11 +22,12 @@ echo_err() {
...
@@ -22,11 +22,12 @@ echo_err() {
usage
()
{
usage
()
{
echo
-e
"Usage:
${
1
}
[release] [install] [deploy] [assets] [clean]"
echo
-e
"Usage:
${
1
}
[release] [install] [deploy] [assets] [clean]"
echo
-e
"
\n
Commands:
\n
"
echo
-e
"
\n
Commands:
\n
"
echo
-e
" release builds a release of the current working-tree"
echo
-e
" release builds a release of the current working-tree"
echo
-e
" install builds a release and install it the GOPATH"
echo
-e
" install builds a release and install it the GOPATH"
echo
-e
" deploy builds a release of the current working-tree and deploys it"
echo
-e
" deploy builds a release of the current working-tree and deploys it"
echo
-e
" assets move and download all the required assets (see: ./assets/externals)"
echo
-e
" docker-dev builds a cozy-app-dev docker image"
echo
-e
" clean remove all generated files from the working-tree"
echo
-e
" assets move and download all the required assets (see: ./assets/externals)"
echo
-e
" clean remove all generated files from the working-tree"
echo
-e
"
\n
Environment variables:"
echo
-e
"
\n
Environment variables:"
echo
-e
"
\n
COZY_ENV"
echo
-e
"
\n
COZY_ENV"
...
@@ -94,19 +95,7 @@ do_prepare_ldflags() {
...
@@ -94,19 +95,7 @@ do_prepare_ldflags() {
do_release
()
{
do_release
()
{
check_env
check_env
do_prepare_ldflags
do_build
do_assets
BINARY
=
"cozy-stack-
${
VERSION_STRING
}
"
go build
-ldflags
"
\
-X github.com/cozy/cozy-stack/pkg/config.Version=
${
VERSION_STRING
}
\
-X github.com/cozy/cozy-stack/pkg/config.BuildTime=
${
BUILD_TIME
}
\
-X github.com/cozy/cozy-stack/pkg/config.BuildMode=
${
BUILD_MODE
}
"
\
-o
"
${
BINARY
}
"
openssl dgst
-sha256
-hex
"
${
BINARY
}
"
>
"
${
BINARY
}
.sha256"
openssl dgst
-sha256
-hex
"
${
BINARY
}
"
>
"
${
BINARY
}
.sha256"
printf
"
${
BINARY
}
\t
"
printf
"
${
BINARY
}
\t
"
...
@@ -124,6 +113,26 @@ do_install() {
...
@@ -124,6 +113,26 @@ do_install() {
-X github.com/cozy/cozy-stack/pkg/config.BuildMode=
${
BUILD_MODE
}
"
-X github.com/cozy/cozy-stack/pkg/config.BuildMode=
${
BUILD_MODE
}
"
}
}
do_build
()
{
check_env
do_prepare_ldflags
do_assets
if
[
-z
"
${
1
}
"
]
;
then
BINARY
=
"cozy-stack-
${
VERSION_STRING
}
"
else
BINARY
=
"
${
1
}
"
fi
go build
-ldflags
"
\
-X github.com/cozy/cozy-stack/pkg/config.Version=
${
VERSION_STRING
}
\
-X github.com/cozy/cozy-stack/pkg/config.BuildTime=
${
BUILD_TIME
}
\
-X github.com/cozy/cozy-stack/pkg/config.BuildMode=
${
BUILD_MODE
}
"
\
-o
"
${
BINARY
}
"
}
# The deploy command will build a new release and deploy it on a
# The deploy command will build a new release and deploy it on a
# distant server using scp. To configure the distance server, you can
# distant server using scp. To configure the distance server, you can
# use the environment variables (see help usage):
# use the environment variables (see help usage):
...
@@ -168,6 +177,25 @@ do_assets() {
...
@@ -168,6 +177,25 @@ do_assets() {
clean_assets
clean_assets
}
}
do_docker_dev_image
()
{
docker_work_dir
=
"
${
WORK_DIR
}
/.docker-work"
mkdir
"
${
docker_work_dir
}
"
trap
"trap - SIGTERM && rm -rf "
${
docker_work_dir
}
" > /dev/null -- -
${
$}
" SIGINT SIGTERM EXIT
cp "
${
WORK_DIR
}
/scripts/Dockerfile
" "
${
docker_work_dir
}
"
cp "
${
WORK_DIR
}
/scripts/cozy-app-dev.sh
" "
${
docker_work_dir
}
"
export GOOS=linux
export GOARCH=386
export COZY_ENV=development
do_build "
${
docker_work_dir
}
/cozy-stack
"
docker build -t cozy/cozy-app-dev "
${
docker_work_dir
}
"
rm -rf "
${
docker_work_dir
}
"
}
clean_assets() {
clean_assets() {
rm -rf "
${
WORK_DIR
}
/.assets
"
rm -rf "
${
WORK_DIR
}
/.assets
"
}
}
...
@@ -279,6 +307,10 @@ case "${1}" in
...
@@ -279,6 +307,10 @@ case "${1}" in
do_assets
do_assets
;;
;;
docker-dev)
do_docker_dev_image
;;
*)
*)
usage "
${
0
}
"
usage "
${
0
}
"
exit 1
exit 1
...
...
This diff is collapsed.
Click to expand it.
scripts/cozy-app-dev.sh
+
20
−
18
View file @
2934e508
...
@@ -56,41 +56,43 @@ usage() {
...
@@ -56,41 +56,43 @@ usage() {
echo
-e
" the script won't try to start couchdb."
echo
-e
" the script won't try to start couchdb."
}
}
if
[
-n
"
${
COZY_STACK_PATH
}
"
]
&&
[
!
-f
"
${
COZY_STACK_PATH
}
"
]
;
then
echo_err
"COZY_STACK_PATH=
${
COZY_STACK_PATH
}
file does not exist"
exit
1
fi
if
[
"
${
COZY_STACK_PORT
}
"
=
"
${
COZY_PROXY_PORT
}
"
]
;
then
if
[
"
${
COZY_STACK_PORT
}
"
=
"
${
COZY_PROXY_PORT
}
"
]
;
then
echo_err
"COZY_STACK_HOST and COZY_PROXY_PORT are equal"
echo_err
"COZY_STACK_HOST and COZY_PROXY_PORT are equal"
exit
1
exit
1
fi
fi
do_start
()
{
do_start
()
{
if
[
!
-f
"
${
GOPATH
}
/bin/caddy"
]
;
then
if
[
-z
"
${
COZY_PROXY_PATH
}
"
]
;
then
if
[
-z
`
command
-v
go
`
]
;
then
COZY_PROXY_PATH
=
"
${
GOPATH
}
/bin/caddy"
echo_err
"executable
\"
go
\"
not found in
\$
PATH"
if
[
!
-f
"
${
COZY_PROXY_PATH
}
"
]
;
then
exit
1
if
[
-z
`
command
-v
go
`
]
;
then
echo_err
"executable
\"
go
\"
not found in
\$
PATH"
exit
1
fi
printf
"installing http server (caddy)... "
go get
"github.com/mholt/caddy/caddy"
echo
"ok"
fi
fi
printf
"installing http server (caddy)... "
go get
"github.com/mholt/caddy/caddy"
echo
"ok"
fi
if
[
-n
"
${
cozy_stack_version
}
"
]
;
then
echo_err
"not implemented... we do not have a release yet"
exit
1
fi
fi
if
[
-z
"
${
COZY_STACK_PATH
}
"
]
;
then
if
[
-z
"
${
COZY_STACK_PATH
}
"
]
;
then
COZY_STACK_PATH
=
"
${
GOPATH
}
/bin/cozy-stack"
COZY_STACK_PATH
=
"
${
GOPATH
}
/bin/cozy-stack"
if
[
!
-f
"
${
COZY_STACK_PATH
}
"
]
;
then
if
[
!
-f
"
${
COZY_STACK_PATH
}
"
]
;
then
if
[
-z
`
command
-v
go
`
]
;
then
echo_err
"executable
\"
go
\"
not found in
\$
PATH"
exit
1
fi
printf
"installing cozy-stack... "
printf
"installing cozy-stack... "
go get
"github.com/cozy/cozy-stack"
go get
"github.com/cozy/cozy-stack"
echo
"ok"
echo
"ok"
fi
fi
fi
fi
if
[
-n
"
${
cozy_stack_version
}
"
]
;
then
echo_err
"not implemented... we do not have a release yet"
exit
1
fi
if
[
"
$update
"
=
true
]
;
then
if
[
"
$update
"
=
true
]
;
then
printf
"updating cozy-stack... "
printf
"updating cozy-stack... "
go get
-u
"github.com/cozy/cozy-stack"
go get
-u
"github.com/cozy/cozy-stack"
...
@@ -214,7 +216,7 @@ app.${COZY_PROXY_HOST} { \n\
...
@@ -214,7 +216,7 @@ app.${COZY_PROXY_HOST} { \n\
"
"
printf "
starting caddy on
\"
${
site_root
}
\"
...
"
printf "
starting caddy on
\"
${
site_root
}
\"
...
"
echo -e
${
caddy_file
}
|
${
GOPATH
}
/bin/caddy
\
echo -e
${
caddy_file
}
|
${
COZY_PROXY_PATH
}
\
-quiet
\
-quiet
\
-conf stdin
\
-conf stdin
\
-port
${
COZY_PROXY_PORT
}
&
-port
${
COZY_PROXY_PORT
}
&
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment