Skip to content

Commit

Permalink
docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 committed Jan 30, 2024
1 parent 44157ff commit 8ec7604
Show file tree
Hide file tree
Showing 7 changed files with 23,029 additions and 13,577 deletions.
22 changes: 11 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ FROM node:20-alpine as builder
COPY package*.json ./

RUN apk add --no-cache python3 make g++
RUN npm install -g pnpm
RUN pnpm install --ignore-scripts

RUN npm ci --ignore-scripts

# Hardcode the target arch for now
# ideally do something like
# ENV TARGET_ARCH=if `uname -m` -eq "x86_64"; then echo "386"; else echo ""; fi
ENV TARGET_ARCH="386"
RUN pnpm rebuild bcrypto
RUN pnpm rebuild loady
RUN pnpm rebuild node-jq
RUN pnpm rebuild sqlite3
RUN npm run postinstall -prefix ./node_modules/go-ipfs
RUN npm rebuild bcrypto
RUN npm rebuild loady
RUN npm rebuild node-jq
RUN npm rebuild sqlite3

FROM node:16-alpine as app
FROM node:20-alpine as app

WORKDIR /app

RUN apk add --no-cache curl
RUN apk add --no-cache curl jq

COPY --from=builder node_modules ./node_modules

COPY package.json pnpm-lock.yaml ceramic-config.json jest.config.json babel.config.json tsconfig.json update.sh ci/* ./
COPY package*.json ceramic-config.json jest.config.json babel.config.json tsconfig.json ci/* ./
COPY config ./config
COPY src ./src

RUN npm install -g pnpm
RUN pnpm run build
RUN npm run build

# NODE_ENV must match desired config file to use for tests
ENV NODE_ENV="private-public"
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Building

```
pnpm install
pnpm run build
npm install
npm run build
```

## Running tests
Expand All @@ -13,21 +13,21 @@ There are currently 3 different configurations that the tests can be run in, whi

#### private-public

`NODE_ENV=private-public pnpm run test`
`NODE_ENV=private-public npm run test`

Tests against the two nodes (called 'private' and 'public') running in our infra. Requires no local nodes.

#### local_client-public

`NODE_ENV=local_client-public pnpm run test`
`NODE_ENV=local_client-public npm run test`

Tests integration between a local node and the 'public' node in our infra.
Before running tests a ceramic node connected to the dev-unstable network
must be running on the same machine. The tests communicate to the local node via an http-client.

#### local_node-private

`NODE_ENV=local_node-private pnpm run test`
`NODE_ENV=local_node-private npm run test`

Tests integration between a local node and the 'private' node in our infra.
Before running tests an ipfs node must be running on the same machine.
Expand Down
24 changes: 12 additions & 12 deletions ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@ fi

if [[ $NODE_ENV == "local_node-private" ]]; then
# init config and generate peer id
node_modules/.pnpm/go-ipfs*/node_modules/go-ipfs/bin/ipfs init
node_modules/go-ipfs/go-ipfs/ipfs init

# config changes to match js-ceramic/ipfs-daemon: TODO remove these and ensure still passes
node_modules/.pnpm/go-ipfs*/node_modules/go-ipfs/bin/ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin: "[\"*\"]"
node_modules/.pnpm/go-ipfs*/node_modules/go-ipfs/bin/ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\"GET\", \"POST\"]"
node_modules/.pnpm/go-ipfs*/node_modules/go-ipfs/bin/ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers "[\"Authorization\"]"
node_modules/.pnpm/go-ipfs*/node_modules/go-ipfs/bin/ipfs config --json API.HTTPHeaders.Access-Control-Expose-Headers "[\"Location\"]"
node_modules/.pnpm/go-ipfs*/node_modules/go-ipfs/bin/ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "[\"true\"]"
node_modules/.pnpm/go-ipfs*/node_modules/go-ipfs/bin/ipfs config --json Addresses.Swarm "[\"/ip4/0.0.0.0/tcp/4011\", \"/ip4/0.0.0.0/tcp/4012/ws\"]"
node_modules/.pnpm/go-ipfs*/node_modules/go-ipfs/bin/ipfs config Addresses.API /ip4/0.0.0.0/tcp/5011
node_modules/.pnpm/go-ipfs*/node_modules/go-ipfs/bin/ipfs config Routing.Type dhtclient
node_modules/go-ipfs/go-ipfs/ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin: "[\"*\"]"
node_modules/go-ipfs/go-ipfs/ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\"GET\", \"POST\"]"
node_modules/go-ipfs/go-ipfs/ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers "[\"Authorization\"]"
node_modules/go-ipfs/go-ipfs/ipfs config --json API.HTTPHeaders.Access-Control-Expose-Headers "[\"Location\"]"
node_modules/go-ipfs/go-ipfs/ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "[\"true\"]"
node_modules/go-ipfs/go-ipfs/ipfs config --json Addresses.Swarm "[\"/ip4/0.0.0.0/tcp/4011\", \"/ip4/0.0.0.0/tcp/4012/ws\"]"
node_modules/go-ipfs/go-ipfs/ipfs config Addresses.API /ip4/0.0.0.0/tcp/5011
node_modules/go-ipfs/go-ipfs/ipfs config Routing.Type dhtclient

# start the daemon
node_modules/.pnpm/go-ipfs*/node_modules/go-ipfs/bin/ipfs daemon --enable-pubsub-experiment &
node_modules/go-ipfs/go-ipfs/ipfs daemon --enable-pubsub-experiment &
fi

echo "INFO: Sleeping for ${SLEEP}s"
sleep ${SLEEP} # Give time for services to finish starting up before starting tests

if [ "$REPORT_STATUS" = true ]; then
pnpm run test:ci
npm run test:ci
else
pnpm run test
npm run test
fi

exit_code=$?;
Expand Down
6 changes: 2 additions & 4 deletions update.sh → ci/update.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash
#!/bin/sh

set -e

cd $(dirname $0)

deps=$(jq -r '.dependencies | keys | .[]' package.json)
filtered_deps=''
for dep in $deps
Expand Down Expand Up @@ -37,7 +35,7 @@ do
done

# We only care about top level dependencies.
cmd="pnpm update --depth 0 $filtered_deps"
cmd="npm install --ignore-scripts $filtered_deps"
echo "$cmd"
$cmd

Expand Down
Loading

0 comments on commit 8ec7604

Please sign in to comment.