Installation process for OpenMapTiles server without docker - openmaptiles

Is there a way to install OpenMapTiles server without docker? I need to use this on redhat linux and docker needs to be enterprise version in order to use it on redhat. Please let me know.
Thanks

You just need to manually perform all scripts they run inside their separate docker containers.
They set up 1 database server by running the commands in
https://github.com/openmaptiles/openmaptiles-tools/blob/master/docker/postgis/Dockerfile
and
https://github.com/openmaptiles/openmaptiles-tools/blob/master/docker/postgis/initdb-postgis.sh
And then continue to download data in a few different docker files by running some commands, this is a pattern that comes back again and again, run the commands in the Dockerfile and the scripts in for all these subfolders in https://github.com/openmaptiles/openmaptiles-tools/tree/master/docker in the order they appear in the documentation at
https://github.com/openmaptiles/openmaptiles/blob/master/README.md
If you're on ubuntu this should be pretty straightforward.
I don't have access to a redhat linux instance, but after translating those ubuntu commands I got something that worked on centos7, so should work on your RHEL7:
(This needs some serious cleanup, I do not recommend using this in a nice production system. Someone should package these commands up in rpm's and push them to a repository (I didn't have the time at the moment and I'm not sure if someone would actually want to do this, let me know if you would be interested in having rpm's of these tools))
# install dependencies
# Install PostgreSQL and PostGIS
yum -y install epel-release
rpm -ivh https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
yum install postgis30_11 postgresql11-server postgis30_11-client
yum install postgresql11-devel postgis30_11-docs postgis30_11-utils pgrouting_11
# tools needed later
yum install boost169-devel libffi-devel openssl-devel protobuf-lite-devel sparsehash-devel leveldb-devel golang-bin utf8proc-devel sqlite pandoc lbzip2 vim libpng libtiff libjpeg freetype gdal cairo pycairo sqlite geos boost curl libcurl libicu bzip2-devel libpng-devel libtiff-devel zlib-devel libjpeg-devel libxml2-devel python-setuptools proj-devel proj proj-epsg proj-nad freetype-devel libicu-devel gdal-devel sqlite-devel libcurl-devel cairo-devel pycairo-devel geos-devel protobuf-devel protobuf-c-devel lua-devel cmake proj boost-thread proj-devel autoconf automake libtool pkgconfig ragel gtk-doc glib2 glib2-devel libpng libpng-devel libwebp libtool-ltdl-devel python-devel harfbuzz harfbuzz-devel harfbuzz-icu boost-devel cabextract xorg-x11-font-utils fontconfig perl-DBD-Pg mesa-libGLU-devel graphviz sqlite3 aria2 osmctools python3 wget
# GCC++ 14 standards are required for Mapnik so we shall install the Dev Toolset from the CentOS Software Collections
yum install centos-release-scl
yum install devtoolset-6
scl enable devtoolset-6 bash
export JOBS=$(nproc)
# Initialise PostgreSQL and Basic Setup
/usr/pgsql-11/bin/postgresql-11-setup initdb
systemctl enable postgresql-11.service
cd /var/lib/pgsql/11
vim data/postgresql.conf
# Add the IP addresses on which the server should listen for connections
listen_addresses = 'localhost,192.168.1.1'
systemctl start postgresql-11.service
vim /etc/profile.d/pgsql.sh
$ export PATH=$PATH:/usr/pgsql-11/bin:/usr/pgsql-11/lib:/usr/local/lib
source /etc/profile.d/pgsql.sh
git clone https://github.com/loretoparisi/kakasi.git
cd kakasi
./configure && make
make install
vim /etc/ld.so.conf.d/libkakasi.conf
/usr/lib64
/usr/local/lib
ldconfig
cd ..
git clone https://github.com/openmaptiles/mapnik-german-l10n.git
cd mapnik-german-l10n
make
make install
su - postgres
psql --dbname="openmaptiles" <<-'EOSQL'
CREATE DATABASE template_postgis;
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';
EOSQL
# i don't find this step anywhere, but it is needed
psql
CREATE DATABASE openmaptiles;
for db in template_postgis "openmaptiles"; do
psql --dbname="$db" <<-'EOSQL'
CREATE EXTENSION postgis;
CREATE EXTENSION hstore;
CREATE EXTENSION unaccent;
CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION osml10n;
EOSQL
done
# these 3 commands start a docker container that downlaods data
#make import-water
#make import-natural-earth
#make import-lakelines
cd
mkdir data
cd data
wget --quiet http://osmdata.openstreetmap.de/download/water-polygons-split-3857.zip
unzip -oj water-polygons-split-3857.zip
su - postgres
ogr2ogr -progress -f Postgresql -s_srs EPSG:3857 -t_srs EPSG:3857 -lco OVERWRITE=YES -lco GEOMETRY_NAME=geometry -nln "osm_ocean_polygon" -nlt geometry --config PG_USE_COPY YES PG:"dbname=openmaptiles" "/root/data/water_polygons.shp"
wget --quiet http://naciscdn.org/naturalearth/packages/natural_earth_vector.sqlite.zip
unzip -oj natural_earth_vector.sqlite.zip -d . '*natural_earth_vector.sqlite'
wget https://raw.githubusercontent.com/openmaptiles/openmaptiles-tools/master/docker/import-natural-earth/clean-natural-earth.sh
hmod +x clean-natural-earth.sh
NATURAL_EARTH_DB=./natural_earth_vector.sqlite ./clean-natural-earth.sh
ogr2ogr -progress -f Postgresql -s_srs EPSG:4326 -t_srs EPSG:3857 -clipsrc -180.1 -85.0511 180.1 85.0511 -lco GEOMETRY_NAME=geometry -lco OVERWRITE=YES -lco DIM=2 -nlt GEOMETRY -overwrite PG:"dbname=openmaptiles" "natural_earth_vector.sqlite"
wget https://github.com/lukasmartinelli/osm-lakelines/releases/download/v0.9/lake_centerline.geojson
ogr2ogr -progress -f Postgresql -s_srs EPSG:4326 -t_srs EPSG:3857 -lco OVERWRITE=YES -overwrite -nln "lake_centerline" PG:"dbname=openmaptiles" "lake_centerline.geojson"
quit
cd data
#get some pbf
wget https://download.geofabrik.de/europe/belgium-latest.osm.pbf
# make import-osm
export GOPATH=~/.go
mkdir -p $GOPATH/src/github.com/omniscale/imposm3
#export IMPOSM_REPO="https://github.com/openmaptiles/imposm3.git"
export IMPOSM_REPO="https://github.com/omniscale/imposm3.git"
#export IMPOSM_VERSION="v2017-10-18"
export IMPOSM_VERSION="v0.8.1"
cd $GOPATH/src/github.com/omniscale/imposm3
go get github.com/tools/godep
go get -u github.com/golang/protobuf/protoc-gen-go
git clone --quiet --depth 1 $IMPOSM_REPO -b $IMPOSM_VERSION $GOPATH/src/github.com/omniscale/imposm3
make build
/usr/local/bin/generate-imposm3 /root/openmaptiles/openmaptiles.yaml > mapping.yaml
export DIFF_DIR=~/data/import
mkdir $DIFF_DIR
export IMPOSM_CACHE_DIR=/tmp/cache
mkdir $IMPOSM_CACHE_DIR
wget https://raw.githubusercontent.com/openmaptiles/openmaptiles-tools/master/docker/import-osm/config.json
./imposm import -connection "postgis://postgres#localhost/openmaptiles" -mapping mapping.yaml -overwritecache -diffdir "$DIFF_DIR" -cachedir "$IMPOSM_CACHE_DIR" -read "$pbf_file" -deployproduction -write $diff_flag -config "$CONFIG_JSON"
# make import-borders
cd
git clone https://github.com/mapbox/protozero
cd protozero
mkdir build
cd build
cmake ..
make -j ${JOBS}
make install
cd
git clone https://github.com/osmcode/libosmium.git
cd libosmium
mkdir build
cmake ..
make -j ${JOBS}
make install
cd
git clone https://github.com/pnorman/osmborder.git
cd osmborder
mkdir build
cmake ..
make -j ${JOBS}
make install
cd
git clone https://github.com/openmaptiles/openmaptiles-tools.git
cd openmaptiles-tools/bin
export PGHOST=localhost
export PGDATABASE=openmaptiles
export PGUSER=postgres
export PGPASSWORD=
./import-borders ~/data/belgium-latest.osm.pbf
# make import-wikidata
cd
wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
tar xf Python-3.8.2
cd Python-3.8.2
./configure --enable-optimizations
make -j ${JOBS} altinstall
cd ~/openmaptiles-tools/bin
python3.8 -m pip install --upgrade pip
python3.8 -m pip install -r ../requirements.txt
export PYTHONPATH=$PYTHONPATH:$PWD/../
# workaround for asyncpg.exceptions.UndefinedTableError: relation "wd_names" does not exist
# see https://github.com/openmaptiles/openmaptiles/pull/785
su - postgres
psql openmaptiles
$ CREATE TABLE IF NOT EXISTS wd_names (id varchar(20) UNIQUE, page varchar(200) UNIQUE, labels hstore);
$ TRUNCATE wd_names;
$ quit
quit
python3.8 import-wikidata --user=postgres ../../openmaptiles/openmaptiles.yaml
#make
# openmaptiles-tools generate-tm2source openmaptiles.yaml
python3.8 generate-tm2source ../../openmaptiles/openmaptiles.yaml --port 5432 > tm2source.yaml
# openmaptiles-tools generate-sql openmaptiles.yaml
python3.8 generate-sql ../../openmaptiles/openmaptiles.yaml > openmaptiles.sql
#make import-sql
# openmaptiles-tools import-sql
export PSQL_OPTIONS=-a
export OMT_UTIL_DIR=../sql/
export VT_UTIL_DIR=../vt_util_sql/
mkdir $VT_UTIL_DIR
wget https://raw.githubusercontent.com/openmaptiles/postgis-vt-util/master/postgis-vt-util.sql
mv postgis-vt-util.sql ../vt_util_sql/
export SQL_DIR=$PWD
./import-sql
# make generate-tiles
- generate-vectortiles
yum install nodejs xdg-utils
cd
git clone git://github.com/mapnik/mapnik
cd mapnik
git checkout remotes/origin/v3.0.x
./bootstrap.sh
./configure BOOST_INCLUDES=/usr/include/boost169/ BOOST_LIBS=/usr/lib64/boost169/
git submodule sync
git submodule update --init
make -j ${JOBS}
make install
ldconfig
npm install --build-from-source=mapnik -g #mapbox/tiletype mapnik#3.7.2 #mapbox/mbtiles #mapbox/tilelive tilelive-tmsource #mapbox/tilelive-vector tilelive-bridge tilelive-mapnik
cp tm2source.yaml data.yml
sed -i "s|host: .*|host: \"localhost\"|g" data.yml
sed -i "s|port: .*|port: \"5432\"|g" data.yml
sed -i "s|dbname: .*|dbname: \"openmaptiles\"|g" data.yml
sed -i "s|user: .*|user: \"postgres\"|g" data.yml
sed -i "s|password: .*|password: \"$POSTGRES_HOST\"|g" data.yml
export BBOX="-180,-85.0511,180,85.0511"
export MIN_ZOOM=0
export MAX_ZOOM=14
tilelive-copy --scheme=pyramid --bounds=BBOX --timeout="18000000" --concurrency="10"--minzoom=MIN_ZOOM --maxzoom=MAX_ZOOM "tmsource://$PWD" "mbtiles://root/data/tiles.mbtiles"
generate-metadata ~/data/tiles.mbtiles

Related

I got "ERROR nothing RPROVIDES" during bitbake

I tried to run
bitbake core-image-minimal
but I got
ERROR: Nothing RPROVIDES 'libcrypto' (but /home/yocto/fsl-4-14-98/sources/poky/meta/recipes-core/images/core-image-minimal.bb RDEPENDS on or otherwise requires it)
In core-image-minimal.bb I have
SUMMARY = "A console-only image that fully supports the target device \ hardware."
IMAGE_FEATURES += "splash"
LICENSE = "MIT"
inherit core-image
I also got a second error
ERROR: Required build target 'core-image-minimal' has no buildable providers.
Missing or unbuildable dependency chain was: ['core-image-minimal', 'libcrypto']
What am I missing? It's my first time using Yocto.
You can find the tutorial I'm using below:
- prepare system for Yocto
$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
xz-utils debianutils iputils-ping
$ sudo apt-get install libsdl1.2-dev xterm
$ sudo apt-get install make xsltproc docbook-utils fop dblatex xmlto
$ sudo apt-get install ncurses-dev
- setting up repo
$ mkdir ~/bin
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
- Add the following line to the .bashrc file to ensure that the ~/bin folder is in your PATH variable.
export PATH=~/bin:$PATH
- configure git:
$ git config --global user.name "Your Name"
$ git config --global user.email "Your Email"
$ git config --list
NEW YOCTO RELEASE WITH KERNEL 4.14.98 AND OPEN SSL 1.1.1J
----
$ cd /usr/bin
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.6
$ sudo rm python
$ sudo ln -s python3.6 python
- load iMX recipes
$ cd
### OLD RELEASE ### $ mkdir fsl-release-bsp
### OLD RELEASE ### $ cd fsl-release-bsp
### OLD RELEASE ### $ repo init -u https://source.codeaurora.org/external/imx/fsl-arm-yocto-bsp -b imx-4.1-krogoth
### OLD RELEASE ### $ repo sync
$ mkdir fsl-4-14-98
$ cd fsl-4-14-98
$ repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-sumo -m imx-4.14.98-2.3.3.xml
### IMPORTANT ### $ git config --global url."https://".insteadOf git://
$ repo sync
$ sudo rm /usr/bin/python
$ sudo ln -s /usr/bin/python2 /usr/bin/python
- configure machine
$ DISTRO=fsl-imx-fb MACHINE=imx6solosabresd source fsl-setup-release.sh -b rsr1296
- create shared directory
$ mkdir ~/yocto
$ mkdir ~/yocto/download
$ mkdir ~/yocto/sstate-cache
$ gedit conf/local.conf
and add this lines:
DL_DIR="/home/multi/yocto/download"
SSTATE_DIR="/home/multi/yocto/sstate-cache"
CONNECTIVITY_CHECK_URIS ?= "https://www.google.com"
IMAGE_INSTALL_append = "pcsc-lite openssl-bin libcrypto"
PREFERRED_VERSION_openssl = "1.1.1j"
IMAGE_INSTALL_remove += "packagegroup-fsl-optee-imx"
BAD_RECOMMENDATIONS += "udev-hwdb"
comment out this lines
#PACKAGECONFIG_append_pn-qemu-native = " sdl"
#PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"
- update Open SSL to 1.1.1J (http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-connectivity/openssl?h=master)
$ cd ~/fsl-4-14-98/sources/poky/meta/recipes-connectivity
$ mv openssl /home/multi/Documents
$ tar xvzf /home/multi/Documents/openssl_1.1.1j.tar.gz
$ cd -
- compile full system
$ bitbake core-image-minimal
Everything is fine with no errors in log until bitbake core-image-minimal

There is no cubedata.h and contrib directory in Postgresql

I has 128-dimensional vectors of float (face recognition issue). To store these vectors I use datatype cube in Postgresql.
This type has limit by default - 100 dim.
In the psql (PostgreSQL) 10.5 (Ubuntu 10.6-0ubuntu0.18.04.1) this limit don't work: I can store my vector without any problems.
But yeasterday one of my machine was updated to PostgreSQL 10.6 and now I receive an error when try to add new cube-vector into my database. Error about too long vector.
To resolve this problem I have to change this limit in the file cubedata.h which is in contrib directory. But I have no this file and such directory at all!
I try install
sudo apt-get install postgresql-contrib
but, I get the message about the newest postgresql-contrib version is already installed.
After I tried to manually download cubedata.h file into the directory of Postgresql (/usr/share/postgresql/10/extension/), but it doesn't help.
My be someone encountered with such problem?
In Ubuntu 18.04.1 cubedata.h included in the postgres-server-dev-10 package from the PostgreSQL official repository. But prebuilt cube.so included in the postgresql-10 package with default limit.
To increase the limit you should recompile cube.so from source. Below the example of code for the Ubuntu.
Add repository:
PG_VER=10.6
source /etc/os-release
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${VERSION_CODENAME}-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get update
sudo apt-get install -y postgresql-${PG_VER%.*}
Compile cube extension from source:
PG_VER=10.6
sudo apt-get install -y unzip gcc make zlib1g-dev libreadline-dev postgresql-server-dev-${PG_VER%.*} bison flex
wget https://ftp.postgresql.org/pub/source/v${PG_VER}/postgresql-${PG_VER}.tar.bz2 --quiet -O postgresql.tar.bz2
tar xvf postgresql.tar.bz2
cd postgresql-${PG_VER}
./configure
cd contrib/cube
sed -i 's/#define CUBE_MAX_DIM (100)/#define CUBE_MAX_DIM (128)/' cubedata.h
make USE_PGXS=1
sudo make USE_PGXS=1 install
Check result after restart server:
sudo -u postgres psql dbname -c 'CREATE EXTENSION cube'
sudo -u postgres psql dbname -c 'SELECT cube_dim(cube(array(select generate_series(1, 128)))) as dim'

How to upgrade docker-compose to latest version

I have installed docker-compose using the command
sudo apt install docker-compose
It installed docker-compose version 1.8.0 and build unknown
I need the latest version of docker-compose or at least a version of 1.9.0
Can anyone please let me know what approach I should take to upgrade it or uninstall and re-install the latest version.
I have checked the docker website and can see that they are recommending this to install the latest version'
sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
But before that, I have to uninstall the present version, which can be done using the command
sudo rm /usr/local/bin/docker-compose
but this can be used only when the installation was done using curl. I am not sure if the installation was done by curl as I have used
sudo apt install docker-compose
Please let me know what should I do now to uninstall and re-install the docker-compose.
First, remove the old version:
If installed via apt-get
sudo apt-get remove docker-compose
If installed via curl
sudo rm /usr/local/bin/docker-compose
If installed via pip
pip uninstall docker-compose
Then find the newest version on the release page at GitHub or by curling the API and extracting the version from the response using grep or jq (thanks to dragon788, frbl, and Saber Hayati for these improvements):
# curl + grep
VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "\K.*\d')
# curl + jq
VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
Finally, download to your favorite $PATH-accessible location and set permissions:
DESTINATION=/usr/local/bin/docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o $DESTINATION
sudo chmod 755 $DESTINATION
The easiest way to have a permanent and sustainable solution for the Docker Compose installation and the way to upgrade it, is to just use the package manager pip with:
pip install docker-compose
I was searching for a good solution for the ugly "how to upgrade to the latest version number"-problem, which appeared after you´ve read the official docs - and just found it occasionally - just have a look at the docker-compose pip package - it should reflect (mostly) the current number of the latest released Docker Compose version.
A package manager is always the best solution if it comes to managing software installations! So you just abstract from handling the versions on your own.
If you tried sudo apt-get remove docker-compose and get E: Unable to locate package docker-compose, try this method :
This command must return a result, in order to check it is installed here :
ls -l /usr/local/bin/docker-compose
Remove the old version :
sudo rm -rf docker-compose
Download the last version (check official repo : docker/compose/releases) :
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
(replace 1.24.0 if needed)
Finally, apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose
Check version :
docker-compose -v
If the above methods aren't working for you, then refer to this answer: https://stackoverflow.com/a/40554985
curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" > ./docker-compose
sudo mv ./docker-compose /usr/bin/docker-compose
sudo chmod +x /usr/bin/docker-compose
Based on #eric-johnson's answer, I'm currently using this in a script:
#!/bin/bash
compose_version=$(curl https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
output='/usr/local/bin/docker-compose'
curl -L https://github.com/docker/compose/releases/download/$compose_version/docker-compose-$(uname -s)-$(uname -m) -o $output
chmod +x $output
echo $(docker-compose --version)
it grabs the latest version from the GitHub api.
Here is another oneliner to install the latest version of docker-compose using curl and sed.
curl -L "https://github.com/docker/compose/releases/download/`curl -fsSLI -o /dev/null -w %{url_effective} https://github.com/docker/compose/releases/latest | sed 's#.*tag/##g' && echo`/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
Do it in three steps. (showing for apt-get installs)
Uninstall the last one. e.g. for apt-get installs
sudo apt-get remove docker-compose
Install the new one (https://docs.docker.com/compose/install/)
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
and then
sudo chmod +x /usr/local/bin/docker-compose
Check your version
docker-compose --version
Simple Solution to update docker-compose
This will remove the existing binary of docker-compose and install a new version.
sudo cd /usr/local/bin && sudo rm -rf docker-compose
sudo sudo curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x docker-compose
for the latest version visit https://github.com/docker/compose/releases and replace the latest one with v2.1.1
I was trying to install docker-compose on "Ubuntu 16.04.5 LTS" but after installing it like this:
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
I was getting:
-bash: /usr/local/bin/docker-compose: Permission denied
and while I was using it with sudo I was getting:
sudo: docker-compose: command not found
So here's the steps that I took and solved my problem:
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose
sudo chmod +x /usr/bin/docker-compose
use this from command line: sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Write down the latest release version
Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose
Then test version:
$ docker-compose --version
If you installed with pip, to upgrade you can just use:
pip install --upgrade docker-compose
or as Mariyo states with pip3 explicitly:
pip3 install --upgrade docker-compose
Using latest flag in url will redirect you to the latest release of the repo
As OS name is lower case in github's filename, you should convert uname -s to lower case using sed -e 's/\(.*\)/\L\1/'.
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s|sed -e 's/\(.*\)/\L\1/')-$(uname -m)" -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose
On mac (also working on ubuntu):
sudo curl -L "https://github.com/docker/compose/releases/download/<release-version>/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
NOTE: write the as here:
https://github.com/docker/compose/releases
Use,
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose
$ docker-compose -v
Docker Engine and Docker Compose Plugin
Since Microsoft took over Docker they worked on porting docker-compose to their Docker Engine CLI plugins. For future support and updates I would recommend using docker compose plugin (Notice the missing dash) which can be install via the docker-compose-plugin package. The following instructions assume that you are using Ubuntu as Distro or any Distro thats using apt as package manager.
Installation Preparations
Update your mirrors:
sudo apt-get update
Make sure the following packages are installed:
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
After that add the official Docker GPG Key:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
And finally add the the stable repository:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Also make sure Docker Engine and other needed dependencies are installed:
sudo apt-get install docker-ce docker-ce-cli containerd.io
Installation of docker compose plugin
sudo apt-get install docker-compose-plugin
Any future updates of the plugin are easily applied via apt.
For further reference take a look at the official installation instructions of Docker Engine and Docker Compose.
After a lot of looking at ways to perform this I ended up using jq, and hopefully I can expand it to handle other repos beyond Docker-Compose without too much work.
# If you have jq installed this will automatically find the latest release binary for your architecture and download it
curl --silent "https://api.github.com/repos/docker/compose/releases/latest" | jq --arg PLATFORM_ARCH "$(echo `uname -s`-`uname -m`)" -r '.assets[] | select(.name | endswith($PLATFORM_ARCH)).browser_download_url' | xargs sudo curl -L -o /usr/local/bin/docker-compose --url
On ubuntu desktop 18.04.2, I have the 'local' removed from the path when using the curl command to install the package and it works for me. See above answer by Kshitij.
In my case, using Windows + WSL2 with Ubuntu 20.04, was necessary only this:
sudo apt update
and then:
sudo apt upgrade
Centos/RHEL
Follow my answer below if you're using Centos7 with an x86-64 architecture. This answer is also available in my github.
Stop Your Docker Containers
I noticed other answers did not talk about stopping your docker containers/images instances before attempting to upgrade gracefully. Assumptions are inevitable but can be costly. Onward we go!
Options to update Docker-Compose
There are 2 options to upgrade docker-compose if you first downloaded and installed docker-compose using the Curl command.
Using Curl, jq package, and Github's direct URL to the docker-compose repository.
Using Curl, Sed, and Github's direct URL to the docker-compose repository.
Note: some of the commands below require "sudo" privileges.
Demonstration
The script below was saved to a file called "update_docker_compose.sh". You need to give this file executable permissions.
Like so:
chmod +x update_docker_compose.sh
"docker_docker_compose.sh" file content:
#!/bin/bash
# author: fullarray (stackoverflow user)
# Contribution shared on: stackoverflow.com
# Contribution also available on: github.com
# date: 06112022
# Stop current docker container running
docker stop containerID
# Remove current docker network running
docker rm containerID
# Remove image of target application(s)
docker image rm imageID
# Delete either dangling (unatagged images) docker containers or images or network
docker system prune -f
# This step depends on the jq package.
# Uncomment jq package installation command below if using Centos7 x86-64.
# sudo yum install jq
# Declare variable to get latest version of docker-compose from github repository
compose_version=$(curl https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
# Declare variable to target installation directory
target_install_dir='/usr/local/bin/docker-compose'
# Get OS and build (assumes Linux Centos7 and x86_64)
get_local_os_build=$(uname -s)-$(uname -m)
# Execute curl command to carry download and installation operation
curl -L https://github.com/docker/compose/releases/download/$compose_version/docker-compose-$get_local_os_build -o $target_install_dir
# Use chmod to modify permissions to target installation directory (to make it executable)
chmod +x $target_install_dir
# Print docker-compose version to terminal to verify upgrade
$(docker-compose --version)
Edit the script with variables specific to your environment
The script above has a few variables you need to edit with values specific to your docker environment. For instance, you need to replace container ID and image ID with the values that the following commands output.
docker ps
and
docker images output
Once you finalize creating the file (including the edits). Switch to the directory that contains the file. For example, if you created the file in /home/username/script/update_docker_compose.sh
cd /home/username/script
Last, run the script by executing the following
./update_docker_compose.sh
Option 2
Create a script file name "update_docker_compose.sh"
Edit the file and add the following content:
#!/bin/bash
# author: fullarray (stackoverflow user)
# Contribution shared on: stackoverflow.com
# Contribution also available on: github.com
# date: 06112022
# Stop current docker container running
docker stop containerID
# Remove current docker network running
docker rm containerID
# Remove image of target application(s)
docker image rm imageID
# Delete either dangling (unatagged images) docker containers or images or network
docker system prune -f
# Declare variable to target installation directory
target_install_dir='/usr/local/bin/docker-compose'
# Get OS and build (assumes Linux Centos7 and x86_64)
get_local_os_build=$(uname -s)-$(uname -m)
# Execute curl and sed command to carry out download and installation operation
# compose_latest_version=$(curl -L "https://github.com/docker/compose/releases/download/`curl -fsSLI -o /dev/null -w %{url_effective} https://github.com/docker/compose/releases/latest | sed 's#.*tag/##g' && echo`/docker-compose-$get_local_os_build") -o $target_install_dir
# Use chmod to modify permissions to target installation directory (to make it executable)
chmod +x $target_install_dir
# Print docker-compose version to terminal to verify upgrade
$(docker-compose --version)
Edit the script with variables specific to your environment
The script above also has a few variables you need to edit with values specific to your docker environment. For instance, you need to replace container ID and image ID with the values that the following commands output.
docker ps
and
docker images output
Once you finalize creating the file (including the edits). Switch to the directory that contains the file. For example, if you created the file in /home/username/script/update_docker_compose.sh
cd /home/username/script
Last, run the script by executing the following
./update_docker_compose.sh
This is the method of installing docker compose version 2.12.x
Update debian package manager
# apt-get update
# apt-get install docker-compose-plugin
Then install the plugin manualy
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
Give permisson of execution of file
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
Last test the installation
docker compose version
// Docker Composer Version v2.12.2
If you have homebrew you can also install via brew
$ brew install docker-compose
This is a good way to install on a Mac OS system
Most of these solutions are outdated or make you install old version.
To install the latest
sudo apt install jq
DOCKER_COMPOSE_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
sudo curl -L "https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Well, my case was pretty weird. I am using wsl2, and Docker Desktop (Windows 11). I stop getting this error after rename the folder "docker" to "config-dev-server" and update de Dockerfile like this this:
COPY ./docker/apache/apache2.conf /etc/apache2/apache2.conf
to
COPY ./config-dev-server/apache/apache2.conf /etc/apache2/apache2.conf
With a newer Docker Desktop for Mac 3.3.0, you don't need to install Docker Compose as a seperate package. Docker Compose comes as a first class citizen installed with Docker by default. Check out the below CLI:
docker compose version
Docker Compose version 2.0.0-beta.1%

Install MongoDB on Debian Buster

How to install the latest MongoDB 3.4 or even 3.6?
They support with Ubuntu, but my server is Debian Buster and I am stuck with MongoDB 3.2.
I don't know if this is a good idea yet, but I just installed it by adding the sid repos and installing using the mongodb-server package. For me this installs version 3.4.18.
I created /etc/apt/sources.list.d/sid.list with:
deb http://deb.debian.org/debian/ sid main
deb-src http://deb.debian.org/debian/ sid main
then did
apt update
apt install mongodb-server
and verified that it's working by connecting with mongo.
I have found the solution for a build script, the description is found here:
https://github.com/patrikx3/docker-debian-testing-mongodb-stable
The description:
Debian Stretch / Buster / Bullseye / Testing MongoDB and MongoDB Tools build stable builder script, what it does as exactly:
It is basically a built for the latest MongoDB for Debian.
The current varsion is the r4.0.x build (release).
Warning It will remove all mongodb* apt packages in ./scripts/build-server.sh and /etc/systemd/system/mongodb-server.service is replaced.
It install the required apt dependencies and generates the SystemD service and makes it enabled.
Check if the build works (building is below). It runs all tests, so if it works, then it really does, actually. If there is an error, of course, you will not deploy on your server. So, if building and testing works, then it puts the binaries as it follow and you are sure and done.
The build as follows build-server.sh:
#!/usr/bin/env bash
# based on https://github.com/mongodb/mongo/wiki/Build-Mongodb-From-Source
# the current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# if an error exit right away, don't continue the build
set -e
# some info
echo
#echo "Works like command, use a tag: sudo ./scripts/build-server.sh r4.2.0"
echo "Works like command, use a tag: sudo ./scripts/build-server.sh r4.0.12"
echo
# check if we are root
if [[ $EUID -ne 0 ]]; then
echo "This script must be ran via root 'sudo' command or using in 'sudo -i'."
exit 1
fi
# require mongo branch
#if [ -z "${1}" ]; then
# echo "First argument must be the MONGODB_BRANCH for example 'v4.1'"
# exit 1
#fi
#MONGODB_BRANCH="${1}"
# require mongo release
#if [ -z "${2}" ]; then
# echo "The second argument must be the MONGODB_RELEASE for example 'r4.1.0'"
# exit 1
#fi
#MONGODB_RELEASE="${2}"
# require mongo release
if [ -z "${1}" ]; then
echo "The first argument must be the MONGODB_RELEASE for example 'r4.0.12'"
exit 1
fi
MONGODB_RELEASE="${1}"
# delete all mongo other programs, we self compile
apt remove --purge mongo*
# the required packages for debian
apt -y install libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev build-essential gcc python scons git glibc-source libssl-dev python-pip libffi-dev python-dev libcurl4-openssl-dev #libcurl-dev
pip install -U pip pyyaml typing
# generate build directory variable
BUILD=$DIR/../build
# delete previous build directory
rm -rf $BUILD/mongo
# generate new build directory
mkdir -p $BUILD
# the mongodb.conf and systemd services files in a directory variable
ROOT_FS=$DIR/../artifacts/root-filesystem
# find out how many cores we have and we use that many
if [ -z "$CORES" ]; then
CORES=$(grep -c ^processor /proc/cpuinfo)
fi
echo Using $CORES cores
# go to the build directory
pushd $BUILD
# clone the mongo by branch
#git clone -b ${MONGODB_BRANCH} https://github.com/mongodb/mongo.git
# clone the mongo by branch
git clone https://github.com/mongodb/mongo.git
# the mongo directory is a variables
MONGO=$BUILD/mongo
# go to the mongo directory
pushd $MONGO
# checkout the mongo release
git checkout tags/${MONGODB_RELEASE}
# hack to old version python pip cryptography from 1.7.2 to use the latest
sed -i 's#cryptography == 1.7.2#\#cryptography == 1.7.2#g' buildscripts/requirements.txt
# this is only because 4.0.12 uses 1.7.2 and
# https://github.com/pyca/cryptography/issues/4193#issuecomment-381236459
# support minimum latest (2.2)
pip install cryptography
# install the python requirements
#pip install -r etc/pip/dev-requirements.txt
pip install -r buildscripts/requirements.txt
# somewhere in the build it says if we install this, it is faster to build
pip2 install --user regex
# build everything
scons all --disable-warnings-as-errors -j $CORES --ssl
# install the mongo programs all
scons install --disable-warnings-as-errors -j $CORES --prefix /usr
# create a copy of the old config
#TIMESTAMP=$(($(date +%s%N)/1000000))
#cp /etc/mongodb.conf /etc/mongodb.conf.$TIMESTAMP.save
# copy the mongodb.conf configured and the systemd service file
# dangerous!!! removed
# cp -avr $ROOT_FS/. /
MONGODB_SERVICE=etc/systemd/system/mongodb-server.service
cp $ROOT_FS/$MONGODB_SERVICE /$MONGODB_SERVICE
chown root:root /$MONGODB_SERVICE
chmod o-rwx /$MONGODB_SERVICE
# generate mongodb user and group
useradd mongodb -d /var/lib/mongodb -s /bin/false || true
# create the required mongodb database directory and add safety
mkdir -p /var/lib/mongodb
chmod o-rwx -R /var/lib/mongodb
chown -R mongodb:mongodb /var/lib/mongodb
# create the required mongodb log directory and add safety
mkdir -p /var/log/mongodb
chmod o-rwx -R /var/log/mongodb
chown -R mongodb:mongodb /var/log/mongodb
# create the required run socket directory and add safety
mkdir -p /run/mongodb
chmod o-rwx -R /run/mongodb
chown -R mongodb:mongodb /run/mongodb
# add safety to the mongodb config file
chmod o-rwx /etc/mongodb.conf || true
chown mongodb:mongodb /etc/mongodb.conf || true
# reload systemd services
systemctl daemon-reload
# enable the mongodb-server
systemctl enable mongodb-server
# start the mongodb-server
#service mongodb-server start
# exit of the mongo directory
popd
# exit the build directory
popd
# delete current build directory
rm -rf $BUILD/mongo
The build as follows build-tools.sh:
#!/usr/bin/env bash
# based on https://github.com/mongodb/mongo-tools
# the current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# if an error exit right away, don't continue the build
set -e
# some info
echo
echo "Works like command: sudo ./scripts/build-tools.sh r4.0.12"
echo
# check if we are root
if [[ $EUID -ne 0 ]]; then
echo "This script must be ran via root 'sudo' command or using in 'sudo -i'."
exit 1
fi
# require mongo release
if [ -z "${1}" ]; then
echo "The first argument must be the MONGODB_RELEASE for example 'r4.0.12'"
exit 1
fi
MONGODB_RELEASE="${1}"
## delete all mongo other programs, we self compile
##apt remove --purge mongo*
## the required packages for debian
##apt -y install gcc python scons git glibc-source libssl-dev python-pip
apt -y install golang libpcap-dev
export GOROOT=$(go env GOROOT)
# generate build directory variable
BUILD=$DIR/../build/src/github.com/mongodb/
# delete previous build directory
rm -rf $BUILD/mongo-tools
# generate new build directory
mkdir -p $BUILD
# find out how many cores we have and we use that many
CORES=$(grep -c ^processor /proc/cpuinfo)
# go to the build directory
pushd $BUILD
# clone the mongo by branch
git clone https://github.com/mongodb/mongo-tools
# the mongo directory is a variables
MONGO_TOOLS=$BUILD/mongo-tools
# go to the mongo directory
pushd $MONGO_TOOLS
# checkout the mongo release
git checkout tags/${MONGODB_RELEASE}
bash ./build.sh
chown root:adm -R ./bin
chmod o-rwx -R ./bin
chmod ug+rx ./bin/*
cp -r ./bin/. /usr/bin
# for PROGRAM in bsondump mongodump mongoexport mongofiles mongoimport mongoreplay mongorestore mongostat mongotop
# do
# go build -o bin/${PROGRAM} -tags "ssl sasl" ${PROGRAM}/main/${PROGRAM}.go
# done
# exit of the mongo directory
popd
# exit the build directory
popd
# delete current build directory
rm -rf $BUILD/mongo-tools
popd
# delete current build directory
rm -rf $BUILD/mongo-tools

unable to install haproxy 1.5 on centos 6.5

I am trying to install haproxy on my centos 6.5 server. I am using the command
yum install haproxy
This command installs a version 1.4.x. I have also looked at the following links, but could not get it to work
http://virtuallyhyper.com/2013/05/configure-haproxy-to-load-balance-sites-with-ssl/
http://blog.haproxy.com/2012/09/10/how-to-get-ssl-with-haproxy-getting-rid-of-stunnel-stud-nginx-or-pound/
https://github.com/bluerail/haproxy-centos
how do i install it?
You can build the RPM as follows:
mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
sudo yum -y install pcre-devel openssl-devel
cd rpmbuild/SOURCES
curl -L -O http://www.haproxy.org/download/1.5/src/haproxy-1.5.3.tar.gz
tar zxf haproxy-1.5.3.tar.gz
cd ..
cp -p SOURCES/haproxy-1.5.3/examples/haproxy.spec SPECS/haproxy153.spec
sed -i 's/Release: .*/Release: %{?_release:%{_release}}%{!?_release:1}/' SPECS/haproxy153.spec
sed -i 's/USE_PCRE=1 /USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 /' SPECS/haproxy153.spec
rpmbuild --define "_topdir `pwd`" --define "_release 2" -bb SPECS/haproxy153.spec
(I use a local directory and set the release number otherwise it is the same as http://qiita.com/uemura/items/e822c1ed505b9fe0208f)
Install
scp RPMS/x86_64/haproxy-1.5.3-2.x86_64.rpm root#somewhere:~/
somewhere# yum localinstall ~/haproxy-1.5.3-2.x86_64.rpm
You could install from source using one of these tar bundles:
http://www.haproxy.org/download/1.5/src/
You will probably need to install the following bundles to compile from source:
yum openssl-devel pcre-devel make gcc
Here's also a script which I presume would work on your environment