Skip to content

Commit

Permalink
Base on couchbase-quickinit (#48)
Browse files Browse the repository at this point in the history
This provides a consistent implementation between couchbase-quickinit
and couchbasefakeit. Because FakeIt has become a bit dated, it isn't
compatible with modern Node or ARM64. We can have couchbase-quickinit
remain more modern and install older tools (bloating size slightly)
in this image for FakeIt support.

Fixes #47
  • Loading branch information
brantburnett authored Dec 3, 2023
1 parent 3f8041a commit a5fbc63
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 433 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ jobs:
strategy:
matrix:
couchbase-version:
- enterprise-6.6.0
- enterprise-6.6.6
- community-7.0.2
- enterprise-7.0.5
- community-7.1.1
- enterprise-7.1.5
- enterprise-7.1.6
- community-7.2.2
- enterprise-7.2.2
- enterprise-7.2.3

steps:
- uses: actions/checkout@v4
Expand Down
66 changes: 31 additions & 35 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
ARG COUCHBASE_TAG=community-6.5.1
FROM couchbase:${COUCHBASE_TAG}

# Configure apt-get for NodeJS
# Install NPM and NodeJS and jq, with apt-get cleanup
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
apt-get install -yq build-essential nodejs jq && \
apt-get autoremove && apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Upgrade to jq 1.6
RUN wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && \
chmod +x jq-linux64 && \
mv jq-linux64 $(which jq)

# Install couchbase-index-manager
RUN mkdir -p /npm-packages && \
npm config set prefix /npm-packages && \
npm install -g --unsafe-perm [email protected] && \
rm -rf /tmp/* /var/tmp/*
ENV PATH="/npm-packages/bin:$PATH"
ARG COUCHBASE_TAG=enterprise-7.2.3
FROM btburnett3/couchbase-quickinit:${COUCHBASE_TAG} as base

# Install Node 12 because fakeit isn't compatible with newer versions
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash && \
rm -f $HOME/.npmrc
ENV NVM_DIR=/root/.nvm
RUN \. $NVM_DIR/nvm.sh && \
nvm install 12.22.12



FROM base as restore

# Install build essentials in a separate stage because we only need it during restore
RUN apt-get update && \
apt-get install build-essential -y

# Copy package.json
WORKDIR /scripts
WORKDIR /fakeit
COPY ./scripts/package*.json ./

# Install fakeit
RUN npm ci && \
rm -rf /tmp/* /var/tmp/*
RUN \. $NVM_DIR/nvm.sh && \
nvm use 12.22.12 && \
npm ci

# Copy startup scripts
COPY ./scripts/ /scripts/
COPY ./startup/ /startup/

# Configure default environment
ENV CB_DATARAM=512 CB_INDEXRAM=256 CB_SEARCHRAM=256 CB_ANALYTICSRAM=1024 CB_EVENTINGRAM=256 \
CB_SERVICES=kv,n1ql,index,fts CB_INDEXSTORAGE=forestdb \
CB_USERNAME=Administrator CB_PASSWORD=password \
FAKEIT_BUCKETTIMEOUT=5000

RUN mkdir /nodestatus
VOLUME /nodestatus
FROM base as final

# Copy node_modules
COPY --from=restore /fakeit/node_modules/ /fakeit/node_modules/

ENTRYPOINT ["./configure-node.sh"]
# Copy startup scripts
COPY ./scripts/ /fakeit/
RUN echo "/fakeit/run-fakeit.sh" >> /scripts/additional-init.sh

# Configure default environment
ENV FAKEIT_BUCKETTIMEOUT=5000
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ couchbasefakeit is a Docker image designed for testing and local development. I

This can be very useful in reducing developer friction, providing a way to quickly and easily spin up a Couchbase server preinitialized for your application. By including an Dockerfile and associated configuration files within your source control repo, you can version your development data definitions along with your application.

> **NOTE:** couchbasefakeit is built on top of [couchbase-quickinit](https://github.com/brantburnett/couchbase-quickinit), adding support for data generation using FakeIt. If you do not require data generation, simply use `couchbase-quickinit` directly.
## Pulling

The latest version can be pulled using:

```sh
docker pull btburnett3/couchbasefakeit:latest
docker pull btburnett3/couchbasefakeit:enterprise-7.2.3
```

The `latest` tag will be the latest Enterprise edition of Couchbase, with the latest release of FakeIt.

Specific versions may also be available, such as `enterprise-4.6.3`. This would be the Enterprise edition of Couchbase, version 4.6.3.
Other may also be available, such as `community-7.0.2`. This would be the Community edition of Couchbase, version 7.0.2.

## Using couchbasefakeit

Expand Down
2 changes: 1 addition & 1 deletion example/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"

services:
couchbase:
image: btburnett3/couchbasefakeit:enterprise-7.0.3
image: btburnett3/couchbasefakeit:enterprise-7.2.3
environment:
- CB_SERVICES=kv,n1ql,index,fts,eventing,cbas
volumes:
Expand Down
27 changes: 0 additions & 27 deletions scripts/configure-analytics.sh

This file was deleted.

36 changes: 0 additions & 36 deletions scripts/configure-node.sh

This file was deleted.

30 changes: 0 additions & 30 deletions scripts/create-buckets.sh

This file was deleted.

25 changes: 0 additions & 25 deletions scripts/create-collections.sh

This file was deleted.

20 changes: 0 additions & 20 deletions scripts/create-events.sh

This file was deleted.

49 changes: 0 additions & 49 deletions scripts/create-fts-indexes.sh

This file was deleted.

31 changes: 0 additions & 31 deletions scripts/create-n1ql-indexes.sh

This file was deleted.

19 changes: 0 additions & 19 deletions scripts/create-rbac-users.sh

This file was deleted.

17 changes: 0 additions & 17 deletions scripts/create-views.sh

This file was deleted.

Loading

0 comments on commit a5fbc63

Please sign in to comment.