Skip to content

Commit 3473b78

Browse files
authored
Merge pull request laradock#275 from luciano-jr/feature/aerospike-cache
Feature/aerospike cache
2 parents 79ff092 + 1a5c7a7 commit 3473b78

8 files changed

Lines changed: 187 additions & 2 deletions

File tree

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Let's see how easy it is to install `NGINX`, `PHP`, `Composer`, `MySQL` and `Red
120120
- **Cache Engines:**
121121
- Redis
122122
- Memcached
123+
- Aerospike
123124
- **PHP Servers:**
124125
- NGINX
125126
- Apache2
@@ -250,7 +251,7 @@ docker-compose up -d nginx mysql
250251

251252
You can select your own combination of Containers form the list below:
252253

253-
`nginx`, `hhvm`, `php-fpm`, `mysql`, `redis`, `postgres`, `mariadb`, `neo4j`, `mongo`, `apache2`, `caddy`, `memcached`, `beanstalkd`, `beanstalkd-console`, `rabbitmq`, `workspace`, `phpmyadmin`.
254+
`nginx`, `hhvm`, `php-fpm`, `mysql`, `redis`, `postgres`, `mariadb`, `neo4j`, `mongo`, `apache2`, `caddy`, `memcached`, `beanstalkd`, `beanstalkd-console`, `rabbitmq`, `workspace`, `phpmyadmin`, `aerospike`.
254255

255256

256257
**Note**: `workspace` and `php-fpm` will run automatically in most of the cases, so no need to specify them in the `up` command.
@@ -995,7 +996,40 @@ It should be like this:
995996

996997
3 - Re-build the container `docker-compose build workspace`
997998

999+
<br>
1000+
<a name="Install-Aerospike-Extension"></a>
1001+
### Install Aerospike extension
1002+
1003+
1 - First install `aerospike` in the Workspace and the PHP-FPM Containers:
1004+
<br>
1005+
a) open the `docker-compose.yml` file
1006+
<br>
1007+
b) search for the `INSTALL_AEROSPIKE_EXTENSION` argument under the Workspace Container
1008+
<br>
1009+
c) set it to `true`
1010+
<br>
1011+
d) search for the `INSTALL_AEROSPIKE_EXTENSION` argument under the PHP-FPM Container
1012+
<br>
1013+
e) set it to `true`
1014+
1015+
It should be like this:
1016+
1017+
```yml
1018+
workspace:
1019+
build:
1020+
context: ./workspace
1021+
args:
1022+
- INSTALL_AEROSPIKE_EXTENSION=true
1023+
...
1024+
php-fpm:
1025+
build:
1026+
context: ./php-fpm
1027+
args:
1028+
- INSTALL_AEROSPIKE_EXTENSION=true
1029+
...
1030+
```
9981031

1032+
2 - Re-build the containers `docker-compose build workspace php-fpm`
9991033

10001034
<br>
10011035
<a name="debugging"></a>

aerospike/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM aerospike:latest
2+
3+
MAINTAINER Luciano Jr <luciano@lucianojr.com.br>
4+
5+
RUN rm /etc/aerospike/aerospike.conf
6+
7+
ADD aerospike.conf /etc/aerospike/aerospike.conf

aerospike/aerospike.conf

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Aerospike database configuration file.
2+
3+
# This stanza must come first.
4+
service {
5+
user root
6+
group root
7+
paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.
8+
pidfile /var/run/aerospike/asd.pid
9+
service-threads 4
10+
transaction-queues 4
11+
transaction-threads-per-queue 4
12+
proto-fd-max 15000
13+
}
14+
15+
logging {
16+
17+
# Log file must be an absolute path.
18+
file /var/log/aerospike/aerospike.log {
19+
context any info
20+
}
21+
22+
# Send log messages to stdout
23+
console {
24+
context any critical
25+
}
26+
}
27+
28+
network {
29+
service {
30+
address any
31+
port 3000
32+
33+
# Uncomment the following to set the `access-address` parameter to the
34+
# IP address of the Docker host. This will the allow the server to correctly
35+
# publish the address which applications and other nodes in the cluster to
36+
# use when addressing this node.
37+
# access-address <IPADDR>
38+
}
39+
40+
heartbeat {
41+
42+
# mesh is used for environments that do not support multicast
43+
mode mesh
44+
port 3002
45+
46+
# use asinfo -v 'tip:host=<ADDR>;port=3002' to inform cluster of
47+
# other mesh nodes
48+
mesh-port 3002
49+
50+
interval 150
51+
timeout 10
52+
}
53+
54+
fabric {
55+
port 3001
56+
}
57+
58+
info {
59+
port 3003
60+
}
61+
}
62+
63+
namespace test {
64+
replication-factor 2
65+
memory-size 1G
66+
default-ttl 5d # 5 days, use 0 to never expire/evict.
67+
68+
# storage-engine memory
69+
70+
# To use file storage backing, comment out the line above and use the
71+
# following lines instead.
72+
storage-engine device {
73+
file /opt/aerospike/data/test.dat
74+
filesize 4G
75+
data-in-memory true # Store data in memory in addition to file.
76+
}
77+
}

docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ services:
1212
- INSTALL_MONGO=false
1313
- INSTALL_NODE=false
1414
- INSTALL_DRUSH=false
15+
- INSTALL_AEROSPIKE_EXTENSION=false
1516
- COMPOSER_GLOBAL_INSTALL=false
1617
- INSTALL_WORKSPACE_SSH=false
1718
- PUID=1000
@@ -37,6 +38,7 @@ services:
3738
- INSTALL_ZIP_ARCHIVE=false
3839
- INSTALL_MEMCACHED=false
3940
- INSTALL_OPCACHE=false
41+
- INSTALL_AEROSPIKE_EXTENSION=false
4042
dockerfile: Dockerfile-70
4143
volumes_from:
4244
- volumes_source
@@ -169,6 +171,20 @@ services:
169171
ports:
170172
- "6379:6379"
171173

174+
### Aerospike c Container #########################################
175+
176+
aerospike:
177+
build: ./aerospike
178+
volumes_from:
179+
- workspace
180+
- volumes_data
181+
ports:
182+
- "3000:3000"
183+
- "3001:3001"
184+
- "3002:3002"
185+
- "3003:3003"
186+
187+
172188
### Memcached Container #####################################
173189

174190
memcached:
@@ -270,6 +286,7 @@ services:
270286
- ./data/redis:/data
271287
- ./data/neo4j:/var/lib/neo4j/data
272288
- ./data/mongo:/data/db
289+
- ./data/aerospike:/opt/aerospike/data
273290
- ./data/sessions:/sessions
274291

275292
### Add more Containers below ###############################

php-fpm/Dockerfile-70

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,28 @@ RUN if [ ${INSTALL_MEMCACHED} = true ]; then \
9494
&& docker-php-ext-enable memcached \
9595
;fi
9696

97+
#####################################
98+
# PHP Aerospike:
99+
#####################################
100+
101+
ARG INSTALL_AEROSPIKE_EXTENSION=true
102+
ENV INSTALL_AEROSPIKE_EXTENSION ${INSTALL_AEROSPIKE_EXTENSION}
103+
# Copy aerospike configration for remote debugging
104+
COPY ./aerospike.ini /usr/local/etc/php/conf.d/aerospike.ini
105+
RUN if [ ${INSTALL_AEROSPIKE_EXTENSION} = true ]; then \
106+
# Install the php aerospike extension
107+
curl -L -o /tmp/aerospike-client-php.tar.gz "https://github.com/luciano-jr/aerospike-client-php/archive/master.tar.gz" \
108+
&& mkdir -p aerospike-client-php \
109+
&& tar -C aerospike-client-php -zxvf /tmp/aerospike-client-php.tar.gz --strip 1 \
110+
&& ( \
111+
cd aerospike-client-php/src/aerospike \
112+
&& phpize \
113+
&& ./build.sh \
114+
&& make install \
115+
) \
116+
&& rm /tmp/aerospike-client-php.tar.gz \
117+
;fi
118+
97119
#####################################
98120
# Opcache:
99121
#####################################
@@ -122,4 +144,4 @@ WORKDIR /var/www/laravel
122144

123145
CMD ["php-fpm"]
124146

125-
EXPOSE 9000
147+
EXPOSE 9000

php-fpm/aerospike.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
extension=aerospike.so
2+
aerospike.udf.lua_system_path=/usr/local/aerospike/lua
3+
aerospike.udf.lua_user_path=/usr/local/aerospike/usr-lua

workspace/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,28 @@ RUN if [ ${INSTALL_NODE} = true ]; then \
165165
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> ~/.bashrc \
166166
;fi
167167

168+
#####################################
169+
# PHP Aerospike:
170+
#####################################
171+
USER root
172+
ARG INSTALL_AEROSPIKE_EXTENSION=true
173+
ENV INSTALL_AEROSPIKE_EXTENSION ${INSTALL_AEROSPIKE_EXTENSION}
174+
# Copy aerospike configration for remote debugging
175+
COPY ./aerospike.ini /etc/php/7.0/cli/conf.d/aerospike.ini
176+
RUN if [ ${INSTALL_AEROSPIKE_EXTENSION} = true ]; then \
177+
# Install the php aerospike extension
178+
curl -L -o /tmp/aerospike-client-php.tar.gz "https://github.com/luciano-jr/aerospike-client-php/archive/master.tar.gz" \
179+
&& mkdir -p aerospike-client-php \
180+
&& tar -C aerospike-client-php -zxvf /tmp/aerospike-client-php.tar.gz --strip 1 \
181+
&& ( \
182+
cd aerospike-client-php/src/aerospike \
183+
&& phpize \
184+
&& ./build.sh \
185+
&& make install \
186+
) \
187+
&& rm /tmp/aerospike-client-php.tar.gz \
188+
;fi
189+
168190
#
169191
#--------------------------------------------------------------------------
170192
# Final Touch

workspace/aerospike.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
extension=aerospike.so
2+
aerospike.udf.lua_system_path=/usr/local/aerospike/lua
3+
aerospike.udf.lua_user_path=/usr/local/aerospike/usr-lua

0 commit comments

Comments
 (0)