Skip to content
This repository was archived by the owner on Jan 27, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ tsconfig.tsbuildinfo
# npm/pnpm logs
.pnpm-debug.log
npm-debug.log*
.pnpm-store

# test coverages
coverage
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ protoc 21.10
rust nightly
shellcheck 0.7.2
shfmt 3.4.0
postgres 14.4
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Build the container with:
#
# docker build -t cipherstash-js .
#
# Start a bash shell in the container with:
#
# docker run --mount src=$(pwd),target=/home/cipherstash/build,type=bind -it cipherstash-js bash
#
# From within you can:
#
# cd build
# ./build.sh build # or test # etc

# This will install a base image specific to the host architecture.
FROM ubuntu:latest

# This will force non-interactive apt package installs, choosing sensible
# default options
ARG DEBIAN_FRONTEND=noninteractive

# Add package source for NodeJS 14.X
RUN apt update
RUN apt -y install curl
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -

RUN apt update
RUN apt -y install git build-essential vim \
protobuf-compiler libreadline-dev zlib1g-dev libssl-dev \
uuid-dev unzip postgresql postgresql-contrib nodejs \
shellcheck shfmt libssl-dev pkg-config

RUN sudo; \
useradd --create-home --shell /bin/bash cipherstash; \
/bin/bash -c 'echo "cipherstash:password" | chpasswd'; \
adduser cipherstash sudo

USER cipherstash
WORKDIR /home/cipherstash

# Install Rust
RUN curl --proto '=https' --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/home/cipherstash/.cargo/bin:${PATH}"
RUN rustup default nightly

# Make it so that "npm install -g foo" writes into a location where the
# cipherstash user has write permissions
RUN mkdir -p /home/cipherstash/.local/bin
ENV PATH="${PATH}:/home/cipherstash/.local/bin"
RUN npm config set prefix '/home/cipherstash/.local/'

# Install pnpm
ENV PNPM_HOME="/home/cipherstash/.local/share/pnpm"
ENV PATH="${PATH}:${PNPM_HOME}"
RUN npm install --global pnpm
# When running pnpm in the docker container we need to ensure its store is
# local to the container (and not shared with the store on the host). This is
# because the store uses hard links and hard links do not work across mounts.
RUN pnpm config set store-dir /home/cipherstash/.pnpm-store
26 changes: 14 additions & 12 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@ fi
trap "echo SOMETHING WENT WRONG - please read the logs above and see if it helps you figure out what is wrong - and also ask an engineer help" ERR

setup() {
asdf plugin add postgres || true
asdf plugin add protoc || true
asdf plugin add rust || true
asdf plugin add nodejs || true
asdf plugin add pnpm || true
asdf plugin add shellcheck || true
asdf plugin add shfmt || true

asdf install
asdf reshim
if command -v asdf &> /dev/null; then
asdf plugin add postgres || true
asdf plugin add protoc || true
asdf plugin add rust || true
asdf plugin add nodejs || true
asdf plugin add pnpm || true
asdf plugin add shellcheck || true
asdf plugin add shfmt || true

asdf install
asdf reshim
fi

# Install wasm for @cipherstash/stash-rs
cargo install wasm-pack
cargo install wasm-opt
rustup target add wasm32-unknown-unknown

pnpm install --frozen-lockfile
}

build() {
Expand Down
5 changes: 2 additions & 3 deletions packages/stash-rs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"scripts": {
"clean": "rm -rf ./pkg",
"build": "pnpm rebuild wasm-pack && rm -rf ./pkg && wasm-pack build . --target nodejs && tsc --build && ./fix-imports.sh",
"build": "rm -rf ./pkg && wasm-pack build . --target nodejs && tsc --build && ./fix-imports.sh",
"prepublishOnly": "npm run build",
"test": "cargo test && npx jest"
},
Expand Down Expand Up @@ -52,8 +52,7 @@
"@types/jest": "^27.0.3",
"@types/node": "^17.0.4",
"ts-node": "^10.9.1",
"typescript": "^4.7.4",
"wasm-pack": "^0.10.3"
"typescript": "^4.7.4"
},
"jest": {
"moduleFileExtensions": [
Expand Down
25 changes: 2 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.