Skip to content

Commit

Permalink
Adding VSCode DevContainer support end settingup development environment
Browse files Browse the repository at this point in the history
Signed-off-by: Dusan Malusev <[email protected]>
  • Loading branch information
Dusan Malusev committed Sep 5, 2021
1 parent 1577f0c commit 9495c13
Show file tree
Hide file tree
Showing 10 changed files with 3,163 additions and 10 deletions.
32 changes: 32 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.194.0/containers/docker-existing-dockerfile
{
"name": "Existing Dockerfile",

// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",

// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "../Dockerfile",

// Set *default* container specific settings.json values on container create.
"settings": {},

// Add the IDs of extensions you want installed when the container is created.
"extensions": []

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

// Uncomment the next line to run commands after the container is created - for example installing curl.
// "postCreateCommand": "apt-get update && apt-get install -y curl",

// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],

// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
}
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
/vendor/
/venv/


# Files to ignore
/cassandra.log
/composer.phar
/composer.lock
/tmp/*
*.ac
.phpunit.result.cache
28 changes: 28 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/include/php/main",
"/usr/local/include/php/Zend",
"/usr/local/include/php",
"/usr/local/include/php/TSRM"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "linux-gcc-arm64",
"compilerArgs": [
"-lssl ",
"-lz ",
"-luv ",
"-lm ",
"-lgmp ",
"-lstdc++"
]
}
],
"version": 4
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.associations": {
"php_driver.h": "c",
"php.h": "c"
}
}
27 changes: 27 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "cppbuild",
"command": "make build",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "composer install",
"type": "shell",
"command": "composer install"
},
{
"label": "test",
"group": "test",
"type": "shell",
"command": "composer test"
}
]
}
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM php:8.0

ENV EXT_CASSANDRA_VERSION=master

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php composer-setup.php && php -r "unlink('composer-setup.php');" \
mv composer.phar /bin/composer

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin

RUN docker-php-source extract \
&& apt update -y \
&& apt install python3 pip cmake unzip mlocate build-essential git libuv1-dev libssl-dev libgmp-dev openssl zlib1g-dev libpcre3-dev -y \
&& git clone --branch $EXT_CASSANDRA_VERSION --depth 1 https://github.com/nano-interactive/php-driver.git /usr/src/php/ext/cassandra \
&& cd /usr/src/php/ext/cassandra && git submodule update --init \
&& mkdir -p /usr/src/php/ext/cassandra/lib/cpp-driver/build \
&& cmake -DCMAKE_CXX_FLAGS="-fPIC" -DCASS_BUILD_STATIC=OFF -DCASS_BUILD_SHARED=ON -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_LIBDIR:PATH=lib -DCASS_USE_ZLIB=ON /usr/src/php/ext/cassandra/lib/cpp-driver \
&& make -j8 \
&& make install \
&& install-php-extensions intl zip pcntl gmp ast xdebug

RUN cd /usr/src/php/ext/cassandra/ext \
&& phpize \
&& LDFLAGS="-L/usr/local/lib" LIBS="-lssl -lz -luv -lm -lgmp -lstdc++" ./configure --with-cassandra=/usr/local \
&& make -j8 && make install && updatedb && pip install ccm


CMD ["bash"]
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
LDFLAGS ?= -L/usr/local/lib
LIBS ?= -lssl -lz -luv -lm -lgmp -lstdc++

all: build copy

.PHONY: build
build:
cd ext && phpize
cd ext && ./configure --with-cassandra=/usr/local
cd ext && make -j8
cd ext && make install

config:
cp ./ext/cassandra.ini /usr/local/etc/php/conf.d/cassandra.ini

clean:
cd ext && $(MAKE) clean
23 changes: 16 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "datastax/php-driver",
"name": "nanointeractive/php-driver",
"type": "library",
"description": "DataStax PHP Driver for Apache Cassandra",
"keywords": [
"cassandra",
"nosql",
"database",
"driver",
"datastax"
"datastax",
"nanointeractive"
],
"homepage": "http://datastax.github.io/php-driver/",
"license": "Apache-2.0",
Expand All @@ -21,17 +22,25 @@
"name": "Bulat Shakirzyanov",
"email": "[email protected]",
"homepage": "http://avalanche123.com"
},
{
"name": "Dusan Malusev",
"email": "[email protected]"
},
{
"name": "Marko Dobromirovic",
"email": "[email protected]"
}
],
"require": {
"php": ">=8.0"
},
"require-dev": {
"behat/behat": "~3.7",
"phpunit/php-code-coverage": "~7.0",
"phpunit/php-token-stream": "~3.1",
"phpunit/phpunit": "~8.5",
"symfony/process": "~2.1"
"behat/behat": "^3.7",
"phpunit/php-code-coverage": "^7.0",
"phpunit/php-token-stream": "^3.1",
"phpunit/phpunit": "^8.5",
"symfony/process": "^2.1"
},
"config": {
"bin-dir": "bin/"
Expand Down
Loading

0 comments on commit 9495c13

Please sign in to comment.