Skip to content

Commit

Permalink
Merge pull request #40 from moja-global/feature/vscode_build
Browse files Browse the repository at this point in the history
Adding vscode remote-container development
  • Loading branch information
leitchy authored Jun 2, 2020
2 parents 8aaaa06 + 64b6778 commit fa0d1d9
Show file tree
Hide file tree
Showing 14 changed files with 280 additions and 301 deletions.
6 changes: 6 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM mojaglobal/vscode-baseimage:bionic

ENV DEBIAN_FRONTEND=noninteractive

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog
30 changes: 30 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.117.1/containers/cpp
{
"name": "C++",
"dockerFile": "Dockerfile",
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"austin.code-gnu-global",
"twxs.cmake",
"ms-vscode.cmake-tools"
]

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "gcc -v",

// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "clang-x64",
"configurationProvider": "vector-of-bool.cmake-tools",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
"compileCommands": "${workspaceFolder}/Source/vscodebuild/compile_commands.json",
"configurationProvider": "vector-of-bool.cmake-tools"
}
],
"version": 4
Expand Down
14 changes: 7 additions & 7 deletions Source/.vscode/launch.json → .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"version": "0.2.0",
"configurations": [
{
"name": "g++-7 build and debug active file",
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"program": "${workspaceFolder}/Source/vscodebuild/bin/moja.cli",
"args": [
"--help",
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"cwd": "${workspaceFolder}/Examples",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
Expand All @@ -21,9 +23,7 @@
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++-7 build active file",
"miDebuggerPath": "/usr/bin/gdb"
]
}
]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"cmake.configureArgs": [
"-DCMAKE_BUILD_TYPE=DEBUG",
"-DCMAKE_INSTALL_PREFIX=/usr/local",
"-DENABLE_TESTS:BOOL=OFF",
"-DENABLE_MOJA.MODULES.GDAL=ON",
"-DENABLE_MOJA.MODULES.LIBPQ=ON",
"-DBoost_USE_STATIC_LIBS=OFF",
"-DBUILD_SHARED_LIBS=ON"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ WORKDIR $ROOTDIR/
# Install basic dependencies
RUN apt-get update -y && apt-get install -y --fix-missing --no-install-recommends \
software-properties-common build-essential ca-certificates \
libtool automake zlib1g-dev libspatialite-dev pkg-config sqlite3 \
libtool automake zlib1g-dev libspatialite-dev pkg-config libsqlite3-dev sqlite3 \
python3-dev python3-numpy python3-pip openssl libssl-dev libpq-dev \
libcurl4-gnutls-dev libproj-dev libxml2-dev libexpat-dev libxerces-c-dev \
libgeos-dev libpoppler-dev \
Expand All @@ -50,23 +50,23 @@ RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cm
&& tar xzf cmake-${CMAKE_VERSION}.tar.gz \
&& cd cmake-${CMAKE_VERSION} \
&& ./bootstrap --system-curl --parallel=$NUM_CPU \
&& make --quiet -j $NUM_CPU \
&& .$NUM_CPU \
&& make --quiet install \
&& make clean \
&& cd ..

RUN wget https://github.com/azadkuh/sqlite-amalgamation/archive/${SQLITE_VERSION}.tar.gz \
&& tar -xzf ${SQLITE_VERSION}.tar.gz && mkdir -p sqlite-amalgamation-${SQLITE_VERSION}/build && cd sqlite-amalgamation-${SQLITE_VERSION}/build \
&& cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=$ROOTDIR .. \
&& make --quiet -j $NUM_CPU install/strip \
&& make clean \
&& cd $ROOTDIR/src
# RUN wget https://github.com/azadkuh/sqlite-amalgamation/archive/${SQLITE_VERSION}.tar.gz \
# && tar -xzf ${SQLITE_VERSION}.tar.gz && mkdir -p sqlite-amalgamation-${SQLITE_VERSION}/build && cd sqlite-amalgamation-${SQLITE_VERSION}/build \
# && cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE \
# -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \
# -DBUILD_SHARED_LIBS=ON \
# -DCMAKE_INSTALL_PREFIX=$ROOTDIR .. \
# && make --quiet -j $NUM_CPU install/strip \
# && make clean \
# && cd $ROOTDIR/src

# fix sqlite include location
RUN mv $ROOTDIR/include/sqlite3/sqlite3.h $ROOTDIR/include
# # fix sqlite include location
# RUN mv $ROOTDIR/include/sqlite3/sqlite3.h $ROOTDIR/include

RUN wget https://pocoproject.org/releases/poco-${POCO_VERSION}/poco-${POCO_VERSION}-all.tar.gz \
&& tar -xzf poco-${POCO_VERSION}-all.tar.gz && mkdir poco-${POCO_VERSION}-all/cmake-build && cd poco-${POCO_VERSION}-all/cmake-build \
Expand Down Expand Up @@ -101,7 +101,7 @@ RUN wget https://pocoproject.org/releases/poco-${POCO_VERSION}/poco-${POCO_VERSI
# build user-config.jam files
RUN echo "using python : 3.6 : /usr ;" > ~/user-config.jam

RUN wget https://dl.bintray.com/boostorg/release/${BOOST_VERSION_DOT}/source/boost_${BOOST_VERSION}.tar.bz2 \
RUN wget https://dl.bintray.com/boostorg/release/${BOOST_VERSION_DOT}/source/boost_${BOOST_VERSION}.tar.bz2 \
&& tar --bzip2 -xf boost_${BOOST_VERSION}.tar.bz2 && cd boost_${BOOST_VERSION} \
&& ./bootstrap.sh --prefix=$ROOTDIR \
&& ./b2 -d0 -j $NUM_CPU cxxstd=14 install variant=release link=shared \
Expand Down Expand Up @@ -152,9 +152,3 @@ RUN apt-get update -y \

RUN ldconfig
RUN rm -r $ROOTDIR/src/*






Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#
# ==================================================================================================================

FROM moja/baseimage:ubuntu-18.04
#FROM moja/baseimage:ubuntu-18.04
FROM moja/baseimage:mg

LABEL maintainer="[email protected]"

Expand Down Expand Up @@ -46,7 +47,7 @@ RUN git clone --recursive https://github.com/sebastiandev/zipper.git \
# GET moja.global
RUN git clone --recursive --depth 1 -b ${FLINT_BRANCH} https://github.com/moja-global/FLINT.git flint \
&& mkdir -p flint/Source/build && cd flint/Source/build \
&& cmake -DCMAKE_BUILD_TYPE=RELEASE \
&& cmake -DCMAKE_BUILD_TYPE=DEBUG \
-DCMAKE_INSTALL_PREFIX=$ROOTDIR \
-DENABLE_TESTS:BOOL=OFF \
-DENABLE_MOJA.MODULES.GDAL=ON \
Expand All @@ -55,7 +56,7 @@ RUN git clone --recursive --depth 1 -b ${FLINT_BRANCH} https://github.com/moja-g
-DBUILD_SHARED_LIBS=ON .. \
&& make --quiet -j $NUM_CPU \
&& make --quiet install \
&& make clean \
# && make clean \
&& cd $ROOTDIR/src

RUN ln -s $ROOTDIR/lib/libmoja.modules.* $ROOTDIR/bin
Expand Down
203 changes: 203 additions & 0 deletions Docker/Dockerfile.vscode-base.ubuntu.18.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

# https://hub.docker.com/_/microsoft-vscode-devcontainers
# docker build --build-arg NUM_CPU=8 -t moja/baseimage_vscode:ubuntu-18.04 .

FROM mcr.microsoft.com/vscode/devcontainers/base:ubuntu-18.04
#FROM moja/baseimage:mg

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# This Dockerfile's base image has a non-root user with sudo access. Use the "remoteUser"
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
# will be updated to match your local UID/GID (when using the dockerFile property).
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG NUM_CPU=1

# Configure apt and install packages
RUN apt-get update \
#
# Install C++ tools
&& apt-get -y install --fix-missing \
#--no-install-recommends \
automake \
bash-completion \
build-essential \
ca-certificates \
cmake \
cppcheck \
doxygen \
doxygen-latex \
git \
graphviz \
libcurl4-gnutls-dev \
libexpat-dev \
libgeos-dev \
libpoppler-dev \
libpq-dev \
libproj-dev \
libspatialite-dev \
libsqlite3-dev \
libssl-dev \
libtool \
libxerces-c-dev \
libxml2-dev \
nasm \
openssl \
pkg-config \
postgis \
postgresql-client-10 \
postgresql-server-dev-10 \
python-dev \
python-numpy \
python-pip \
python3-dev \
python3-numpy \
python3-pip \
software-properties-common \
sqlite3 \
valgrind \
wget \
zlib1g-dev \
# [Optional] Update UID/GID if needed
&& if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
groupmod --gid $USER_GID $USERNAME \
&& usermod --uid $USER_UID --gid $USER_GID $USERNAME \
&& chown -R $USER_UID:$USER_GID /home/$USERNAME; \
fi \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

ENV ROOTDIR /usr/local
ENV GDAL_VERSION 2.4.1
ENV CMAKE_VERSION 3.15.4
ENV POCO_VERSION 1.9.2
ENV BOOST_VERSION 1_72_0
ENV BOOST_VERSION_DOT 1.72.0
ENV FMT_VERSION 6.1.2
ENV SQLITE_VERSION 3.31.1

WORKDIR $ROOTDIR/

# set environment variables
ENV PATH $ROOTDIR/bin:$PATH
ENV LD_LIBRARY_PATH $ROOTDIR/lib:$LD_LIBRARY_PATH
ENV PYTHONPATH $ROOTDIR/lib:$PYTHONPATH

WORKDIR $ROOTDIR/src

RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz \
&& tar xzf cmake-${CMAKE_VERSION}.tar.gz \
&& cd cmake-${CMAKE_VERSION} \
&& ./bootstrap --system-curl --parallel=$NUM_CPU \
&& make --quiet install \
&& make clean \
&& cd ..

RUN wget https://pocoproject.org/releases/poco-${POCO_VERSION}/poco-${POCO_VERSION}-all.tar.gz \
&& tar -xzf poco-${POCO_VERSION}-all.tar.gz && mkdir poco-${POCO_VERSION}-all/cmake-build && cd poco-${POCO_VERSION}-all/cmake-build \
&& cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=$ROOTDIR \
-DPOCO_UNBUNDLED=ON \
-DPOCO_STATIC=OFF \
-DENABLE_ENCODINGS=OFF \
-DENABLE_ENCODINGS_COMPILER=OFF \
-DENABLE_XML=OFF \
-DENABLE_JSON=ON \
-DENABLE_MONGODB=OFF \
-DENABLE_REDIS=OFF \
-DENABLE_PDF=OFF \
-DENABLE_UTIL=OFF \
-DENABLE_NET=OFF \
-DENABLE_NETSSL=OFF \
-DENABLE_CRYPTO=OFF \
-DENABLE_DATA=ON \
-DENABLE_DATA_SQLITE=ON \
-DENABLE_DATA_MYSQL=OFF \
-DENABLE_DATA_ODBC=OFF \
-DENABLE_SEVENZIP=OFF \
-DENABLE_ZIP=OFF \
-DENABLE_PAGECOMPILER=OFF \
-DENABLE_PAGECOMPILER_FILE2PAGE=OFF \
-DENABLE_TESTS:BOOL=OFF .. \
&& make --quiet -j $NUM_CPU \
&& make --quiet install/strip \
# && make clean \
&& cd $ROOTDIR/src

# build user-config.jam files
RUN echo "using python : 3.6 : /usr ;" > ~/user-config.jam

RUN wget https://dl.bintray.com/boostorg/release/${BOOST_VERSION_DOT}/source/boost_${BOOST_VERSION}.tar.bz2 \
&& tar --bzip2 -xf boost_${BOOST_VERSION}.tar.bz2 && cd boost_${BOOST_VERSION} \
&& ./bootstrap.sh --prefix=$ROOTDIR \
&& ./b2 -d0 -j $NUM_CPU cxxstd=14 install variant=release link=shared \
# && ./b2 clean \
&& cd $ROOTDIR/src

RUN wget https://github.com/fmtlib/fmt/archive/${FMT_VERSION}.tar.gz \
&& mkdir libfmt-${FMT_VERSION} && tar -xzf ${FMT_VERSION}.tar.gz -C libfmt-${FMT_VERSION} --strip-components=1 && cd libfmt-${FMT_VERSION} \
&& cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=$ROOTDIR \
-DFMT_DOC=OFF \
-DFMT_TEST=OFF . \
&& make --quiet -j $NUM_CPU install/strip \
# && make clean \
&& cd $ROOTDIR/src

RUN git clone --recursive https://github.com/sebastiandev/zipper.git \
&& cd zipper && git checkout e9f150516cb55d194b5e01d21a9527783e98311d && mkdir build && cd build \
&& cmake .. \
&& make --quiet -j $NUM_CPU \
&& make --quiet install \
&& make clean \
&& cd $ROOTDIR/src

RUN wget http://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz \
&& tar -xvf gdal-${GDAL_VERSION}.tar.gz && cd gdal-${GDAL_VERSION} \
&& ./configure --without-libtool --with-hide-internal-symbols \
--with-python --with-spatialite --with-pg --with-curl --prefix=$ROOTDIR \
--with-libtiff=internal --with-rename-internal-libtiff-symbols \
--with-geotiff=internal --with-rename-internal-libgeotiff-symbols \
&& make --quiet -j $NUM_CPU \
&& make install \
# && make clean \
&& cd $ROOTDIR/src
RUN strip -s $ROOTDIR/lib/libgdal.so
RUN for i in $ROOTDIR/lib/python3/dist-packages/osgeo/*.so; do strip -s $i 2>/dev/null || /bin/true; done
RUN strip -s $ROOTDIR/bin/gdal_contour && strip -s $ROOTDIR/bin/gdal_grid \
&& strip -s $ROOTDIR/bin/gdal_rasterize && strip -s $ROOTDIR/bin/gdal_translate && strip -s $ROOTDIR/bin/gdaladdo \
&& strip -s $ROOTDIR/bin/gdalbuildvrt && strip -s $ROOTDIR/bin/gdaldem && strip -s $ROOTDIR/bin/gdalenhance \
&& strip -s $ROOTDIR/bin/gdalinfo && strip -s $ROOTDIR/bin/gdallocationinfo && strip -s $ROOTDIR/bin/gdalmanage \
&& strip -s $ROOTDIR/bin/gdalserver && strip -s $ROOTDIR/bin/gdalsrsinfo && strip -s $ROOTDIR/bin/gdaltindex \
&& strip -s $ROOTDIR/bin/gdaltransform && strip -s $ROOTDIR/bin/gdalwarp && strip -s $ROOTDIR/bin/gnmanalyse \
&& strip -s $ROOTDIR/bin/gnmmanage && strip -s $ROOTDIR/bin/nearblack && strip -s $ROOTDIR/bin/ogr2ogr \
&& strip -s $ROOTDIR/bin/ogrinfo && strip -s $ROOTDIR/bin/ogrlineref && strip -s $ROOTDIR/bin/ogrtindex \
&& strip -s $ROOTDIR/bin/testepsg

ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
ENV GDAL_DATA=/usr/local/share/gdal
ENV GDAL_HTTP_VERSION 2

RUN apt-get update -y \
&& apt-get remove -y --purge build-essential \
&& cd $ROOTDIR/src/gdal-${GDAL_VERSION}/swig/python \
&& python3 setup.py build \
&& python3 setup.py install

RUN cd $ROOTDIR/src/gdal-${GDAL_VERSION}/swig/python \
&& python3 setup.py build \
&& python3 setup.py install

RUN ldconfig

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog
Loading

0 comments on commit fa0d1d9

Please sign in to comment.