Skip to content

Commit 9495c13

Browse files
author
Dusan Malusev
committed
Adding VSCode DevContainer support end settingup development environment
Signed-off-by: Dusan Malusev <[email protected]>
1 parent 1577f0c commit 9495c13

File tree

10 files changed

+3163
-10
lines changed

10 files changed

+3163
-10
lines changed

.devcontainer/devcontainer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.194.0/containers/docker-existing-dockerfile
3+
{
4+
"name": "Existing Dockerfile",
5+
6+
// Sets the run context to one level up instead of the .devcontainer folder.
7+
"context": "..",
8+
9+
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
10+
"dockerFile": "../Dockerfile",
11+
12+
// Set *default* container specific settings.json values on container create.
13+
"settings": {},
14+
15+
// Add the IDs of extensions you want installed when the container is created.
16+
"extensions": []
17+
18+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
19+
// "forwardPorts": [],
20+
21+
// Uncomment the next line to run commands after the container is created - for example installing curl.
22+
// "postCreateCommand": "apt-get update && apt-get install -y curl",
23+
24+
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
25+
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
26+
27+
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
28+
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
29+
30+
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
31+
// "remoteUser": "vscode"
32+
}

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
/vendor/
88
/venv/
99

10-
1110
# Files to ignore
1211
/cassandra.log
13-
/composer.phar
14-
/composer.lock
1512
/tmp/*
13+
*.ac
14+
.phpunit.result.cache

.vscode/c_cpp_properties.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Linux",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"/usr/local/include/php/main",
8+
"/usr/local/include/php/Zend",
9+
"/usr/local/include/php",
10+
"/usr/local/include/php/TSRM"
11+
],
12+
"defines": [],
13+
"compilerPath": "/usr/bin/gcc",
14+
"cStandard": "c17",
15+
"cppStandard": "c++20",
16+
"intelliSenseMode": "linux-gcc-arm64",
17+
"compilerArgs": [
18+
"-lssl ",
19+
"-lz ",
20+
"-luv ",
21+
"-lm ",
22+
"-lgmp ",
23+
"-lstdc++"
24+
]
25+
}
26+
],
27+
"version": 4
28+
}

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"files.associations": {
3+
"php_driver.h": "c",
4+
"php.h": "c"
5+
}
6+
}

.vscode/tasks.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "build",
8+
"type": "cppbuild",
9+
"command": "make build",
10+
"group": {
11+
"kind": "build",
12+
"isDefault": true
13+
}
14+
},
15+
{
16+
"label": "composer install",
17+
"type": "shell",
18+
"command": "composer install"
19+
},
20+
{
21+
"label": "test",
22+
"group": "test",
23+
"type": "shell",
24+
"command": "composer test"
25+
}
26+
]
27+
}

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM php:8.0
2+
3+
ENV EXT_CASSANDRA_VERSION=master
4+
5+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
6+
php composer-setup.php && php -r "unlink('composer-setup.php');" \
7+
mv composer.phar /bin/composer
8+
9+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin
10+
11+
RUN docker-php-source extract \
12+
&& apt update -y \
13+
&& apt install python3 pip cmake unzip mlocate build-essential git libuv1-dev libssl-dev libgmp-dev openssl zlib1g-dev libpcre3-dev -y \
14+
&& git clone --branch $EXT_CASSANDRA_VERSION --depth 1 https://github.com/nano-interactive/php-driver.git /usr/src/php/ext/cassandra \
15+
&& cd /usr/src/php/ext/cassandra && git submodule update --init \
16+
&& mkdir -p /usr/src/php/ext/cassandra/lib/cpp-driver/build \
17+
&& 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 \
18+
&& make -j8 \
19+
&& make install \
20+
&& install-php-extensions intl zip pcntl gmp ast xdebug
21+
22+
RUN cd /usr/src/php/ext/cassandra/ext \
23+
&& phpize \
24+
&& LDFLAGS="-L/usr/local/lib" LIBS="-lssl -lz -luv -lm -lgmp -lstdc++" ./configure --with-cassandra=/usr/local \
25+
&& make -j8 && make install && updatedb && pip install ccm
26+
27+
28+
CMD ["bash"]

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
LDFLAGS ?= -L/usr/local/lib
2+
LIBS ?= -lssl -lz -luv -lm -lgmp -lstdc++
3+
4+
all: build copy
5+
6+
.PHONY: build
7+
build:
8+
cd ext && phpize
9+
cd ext && ./configure --with-cassandra=/usr/local
10+
cd ext && make -j8
11+
cd ext && make install
12+
13+
config:
14+
cp ./ext/cassandra.ini /usr/local/etc/php/conf.d/cassandra.ini
15+
16+
clean:
17+
cd ext && $(MAKE) clean

composer.json

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
2-
"name": "datastax/php-driver",
2+
"name": "nanointeractive/php-driver",
33
"type": "library",
44
"description": "DataStax PHP Driver for Apache Cassandra",
55
"keywords": [
66
"cassandra",
77
"nosql",
88
"database",
99
"driver",
10-
"datastax"
10+
"datastax",
11+
"nanointeractive"
1112
],
1213
"homepage": "http://datastax.github.io/php-driver/",
1314
"license": "Apache-2.0",
@@ -21,17 +22,25 @@
2122
"name": "Bulat Shakirzyanov",
2223
"email": "[email protected]",
2324
"homepage": "http://avalanche123.com"
25+
},
26+
{
27+
"name": "Dusan Malusev",
28+
"email": "[email protected]"
29+
},
30+
{
31+
"name": "Marko Dobromirovic",
32+
"email": "[email protected]"
2433
}
2534
],
2635
"require": {
2736
"php": ">=8.0"
2837
},
2938
"require-dev": {
30-
"behat/behat": "~3.7",
31-
"phpunit/php-code-coverage": "~7.0",
32-
"phpunit/php-token-stream": "~3.1",
33-
"phpunit/phpunit": "~8.5",
34-
"symfony/process": "~2.1"
39+
"behat/behat": "^3.7",
40+
"phpunit/php-code-coverage": "^7.0",
41+
"phpunit/php-token-stream": "^3.1",
42+
"phpunit/phpunit": "^8.5",
43+
"symfony/process": "^2.1"
3544
},
3645
"config": {
3746
"bin-dir": "bin/"

0 commit comments

Comments
 (0)