Skip to content

Commit

Permalink
feat: Infra initailized with docker and kube (keep-starknet-strange#185)
Browse files Browse the repository at this point in the history
<!-- enter the gh issue after hash -->

- [ ] issue #
- [x] follows contribution
[guide](https://github.com/keep-starknet-strange/shinigami/blob/main/CONTRIBUTING.md)
- [ ] code change includes tests

<!-- PR description below -->
  • Loading branch information
b-j-roberts authored Aug 29, 2024
1 parent 1833214 commit 7ac264a
Show file tree
Hide file tree
Showing 12 changed files with 879 additions and 28 deletions.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ test-cairo:
test-core:
@echo "Running bitcoin-core tests..."
@./tests/run-core-tests.sh 0 1207

docker-build:
$(eval COMMIT_SHA := $(shell git rev-parse --short HEAD))
@echo "Building docker images with version $(COMMIT_SHA)"
@echo "Building backend..."
docker build . -f backend/Dockerfile -t "brandonjroberts/shinigami-backend:$(COMMIT_SHA)"

docker-push:
$(eval COMMIT_SHA := $(shell git rev-parse --short HEAD))
@echo "Pushing docker images with version $(COMMIT_SHA)"
@echo "Pushing backend..."
docker push "brandonjroberts/shinigami-backend:$(COMMIT_SHA)"
39 changes: 25 additions & 14 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
FROM node:20.5.0
FROM --platform=linux/amd64 node:21.7.1-alpine

SHELL ["bash", "-c"]
RUN apk add --no-cache bash curl git jq ncurses

SHELL ["/bin/bash", "-c"]
RUN curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v 2.7.1
RUN curl https://get.starkli.sh | sh && \
source $HOME/.starkli/env && \
starkliup && \
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.1 && \
. "$HOME/.asdf/asdf.sh" && \
. "$HOME/.asdf/completions/asdf.bash" && \
asdf plugin add scarb && \
asdf install scarb latest && \
asdf global scarb latest
source /root/.starkli/env && \
starkliup
ENV PATH="$PATH:/root/.local/bin:/root/.starkli/bin"

WORKDIR /backend
WORKDIR /tests

COPY ./index.js ./package.json ./
COPY ./tests/text_to_byte_array.sh ./

WORKDIR /backend

COPY ./backend/package.json ./backend/package-lock.json ./
RUN npm i

EXPOSE 3000
COPY ./backend ./

WORKDIR /

COPY Scarb.toml Scarb.lock .tool-versions ./
COPY ./src ./src
RUN scarb build

WORKDIR /backend

EXPOSE 8080

CMD ["node", "index.js"]
CMD ["node", "index.js"]
10 changes: 0 additions & 10 deletions backend/compose.yaml

This file was deleted.

9 changes: 7 additions & 2 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ function extractStack(output) {
app.use(cors());
app.use(express.json());

// Default route
app.get('/', (_, res) => {
res.sendStatus(200);
});

app.post('/run-script', (req, res) => {
const { pub_key, sig } = req.body;
if (!pub_key) {
Expand Down Expand Up @@ -58,7 +63,7 @@ app.post('/run-script', (req, res) => {
});
});

const PORT = process.env.PORT || 3000;
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
});
Loading

0 comments on commit 7ac264a

Please sign in to comment.