Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #51 from xmtp/rygine/fix-publishing
Browse files Browse the repository at this point in the history
Only publish `/dist` files
  • Loading branch information
rygine authored Jan 20, 2024
2 parents 838a093 + fba0cc0 commit 1796c7d
Show file tree
Hide file tree
Showing 16 changed files with 796 additions and 49 deletions.
10 changes: 10 additions & 0 deletions .changeset/eleven-donkeys-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@xmtp/experimental-content-type-screen-effect": patch
"@xmtp/content-type-reaction": patch
"@xmtp/content-type-read-receipt": patch
"@xmtp/content-type-remote-attachment": patch
"@xmtp/content-type-reply": patch
"@xmtp/content-type-transaction-reference": patch
---

Only publish files in the `/dist` directory
13 changes: 2 additions & 11 deletions dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ services:
POSTGRES_PASSWORD: xmtp

upload-service:
build: ./upload-service
build: ./uploadService
ports:
- 4567:4567

caddy:
image: caddy:latest
ports:
- "443:443"
volumes:
- ./upload-service/Caddyfile:/etc/caddy/Caddyfile
- ./upload-service/data/data:/data
- ./upload-service/data/config:/config
- 3000:3000
4 changes: 0 additions & 4 deletions dev/upload-service/Caddyfile

This file was deleted.

7 changes: 0 additions & 7 deletions dev/upload-service/Dockerfile

This file was deleted.

21 changes: 0 additions & 21 deletions dev/upload-service/app.rb

This file was deleted.

15 changes: 15 additions & 0 deletions dev/uploadService/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Fetching the minified node image on apline linux
FROM node:18.19-slim

WORKDIR /uploadService
COPY . .

RUN apt-get update && \
apt-get install -y openssl && \
openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -sha256 -days 3650 -subj /CN=localhost -out cert.pem

RUN npm install

CMD ["node", "index.js"]

EXPOSE 3000
36 changes: 36 additions & 0 deletions dev/uploadService/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const fs = require("fs");
const https = require("https");
const express = require("express");
const bodyParser = require("body-parser");
const app = express();
const port = 3000;

const key = fs.readFileSync("key.pem", "utf-8");
const cert = fs.readFileSync("cert.pem", "utf-8");

const UPLOADS = {};

app.use(bodyParser.raw({ type: "application/octet-stream" }));

app.get("/:path", (req, res) => {
const path = req.params.path;
console.log(`GET /${path}`);
const file = UPLOADS[path];
if (file) {
res.header("Content-Type", "application/octet-stream");
res.send(file);
} else {
console.log(`Upload path found: ${path}`);
}
});

app.post("/:path", (req, res) => {
const path = req.params.path;
console.log(`POST /${path}`);
UPLOADS[path] = req.body;
res.sendStatus(200);
});

https.createServer({ key, cert }, app).listen(port, () => {
console.log(`Upload service listening on port ${port}`);
});
Loading

0 comments on commit 1796c7d

Please sign in to comment.