Skip to content

Commit 49748df

Browse files
author
chedim
committed
gitpod
1 parent e02eee8 commit 49748df

File tree

4 files changed

+103
-1
lines changed

4 files changed

+103
-1
lines changed

.gitpod.Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM couchbase:latest
2+
3+
RUN echo "* soft nproc 20000\n"\
4+
"* hard nproc 20000\n"\
5+
"* soft nofile 200000\n"\
6+
"* hard nofile 200000\n" >> /etc/security/limits.conf
7+
8+
#Simple example on how to extend the image to install Java and maven
9+
RUN apt-get -qq update && \
10+
apt-get install -yq maven default-jdk sudo git
11+
12+
RUN chmod -R g+rwX /opt/couchbase && \
13+
addgroup --gid 33333 gitpod && \
14+
useradd --no-log-init --create-home --home-dir /home/gitpod --shell /bin/bash --uid 33333 --gid 33333 gitpod && \
15+
usermod -a -G gitpod,couchbase,sudo gitpod && \
16+
echo 'gitpod ALL=(ALL) NOPASSWD:ALL'>> /etc/sudoers
17+
18+
COPY startcb.sh /opt/couchbase/bin/startcb.sh
19+
USER gitpod

.gitpod.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
image:
2+
file: .gitpod.Dockerfile
3+
4+
tasks:
5+
- name: Start Couchbase
6+
command: ./startcb.sh
7+
- name: Log use
8+
command: curl -s 'https://da-demo-images.s3.amazonaws.com/runItNow_outline.png?couchbase-example=java-springdata-quickstart-repo&source=gitpod' > /dev/null
9+
- name: Start app
10+
command: ./gradlew bootRun
11+
# exposed ports
12+
ports:
13+
- port: 8080
14+
onOpen: open-preview
15+
- port: 8091
16+
onOpen: open-browser
17+
- port: 8092-10000
18+
onOpen: ignore
19+
- port: 4369
20+
onOpen: ignore
21+
22+
github:
23+
prebuilds:
24+
# enable for the master/default branch (defaults to true)
25+
master: true
26+
27+
vscode:
28+
extensions:
29+
- redhat.java
30+
- vscjava.vscode-java-debug
31+
- vscjava.vscode-java-test
32+
- pivotal.vscode-spring-boot

src/main/java/trycb/controller/ProfileController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public ResponseEntity<Profile> saveProfile(@RequestBody Profile profile) {
6868
@DeleteMapping("/profile/{id}")
6969
public ResponseEntity<Void> deleteProfile(@PathVariable UUID id) {
7070
try {
71-
profileRepository.deleteById(id);
71+
profileRepository.deleteById(id);
7272
return ResponseEntity.noContent().build();
7373
} catch (DataRetrievalFailureException e) {
7474
LOGGER.error("Document not found", e);

startcb.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
OS_USER_GROUP="${OS_USER_GROUP:=gitpod:gitpod}"
4+
5+
CB_USER="${CB_USER:-Administrator}"
6+
CB_PSWD="${CB_PSWD:-password}"
7+
CB_HOST="${CB_HOST:-127.0.0.1}"
8+
CB_PORT="${CB_PORT:-8091}"
9+
CB_NAME="${CB_NAME:-cbgitpod}"
10+
11+
CB_SERVICES="${CB_SERVICES:-data,query,index,fts,eventing,analytics}"
12+
13+
CB_KV_RAMSIZE="${CB_KV_RAMSIZE:-256}"
14+
CB_INDEX_RAMSIZE="${CB_INDEX_RAMSIZE:-256}"
15+
CB_FTS_RAMSIZE="${CB_FTS_RAMSIZE:-256}"
16+
CB_EVENTING_RAMSIZE="${CB_EVENTING_RAMSIZE:-512}"
17+
CB_ANALYTICS_RAMSIZE="${CB_ANALYTICS_RAMSIZE:-1024}"
18+
19+
set -euo pipefail
20+
21+
COUCHBASE_TOP=/opt/couchbase
22+
sudo chown -R ${OS_USER_GROUP} ${COUCHBASE_TOP}/var
23+
24+
echo "Start couchbase..."
25+
couchbase-server --start
26+
27+
echo "Waiting for couchbase-server..."
28+
until curl -s http://${CB_HOST}:${CB_PORT}/pools > /dev/null; do
29+
sleep 5
30+
echo "Waiting for couchbase-server..."
31+
done
32+
33+
echo "Waiting for couchbase-server... ready"
34+
35+
if ! couchbase-cli server-list -c ${CB_HOST}:${CB_PORT} -u ${CB_USER} -p ${CB_PSWD} > /dev/null; then
36+
echo "couchbase cluster-init..."
37+
couchbase-cli cluster-init \
38+
--services ${CB_SERVICES} \
39+
--cluster-name ${CB_NAME} \
40+
--cluster-username ${CB_USER} \
41+
--cluster-password ${CB_PSWD} \
42+
--cluster-ramsize ${CB_KV_RAMSIZE} \
43+
--cluster-index-ramsize ${CB_INDEX_RAMSIZE} \
44+
--cluster-fts-ramsize ${CB_FTS_RAMSIZE} \
45+
--cluster-eventing-ramsize ${CB_EVENTING_RAMSIZE} \
46+
--cluster-analytics-ramsize ${CB_ANALYTICS_RAMSIZE}
47+
fi
48+
49+
sleep 3
50+
51+

0 commit comments

Comments
 (0)