Skip to content

Commit

Permalink
Introduce CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Jul 22, 2024
1 parent 6401550 commit 417f471
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 2 deletions.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
# v3x-property

## Repo Dev

### Prerequisites

- Docker `docker`
- Docker Buildx `docker-buildx`

## Brainrot

Every hosted instance has a FQDN url, for example `v3x.property` or `property.example.com`.
Instances do not have to be accessible from the internet, they can be local or on a private network (behind VPN or firewall).

An instance consists of a deployment of the `engine` container.
An instance keeps track of the state of all entities within it.

### Entity Identity

An entity is a user, a group or an organization.
Entities are referenced by their path within the INSTANCE_URL of an engine.

```url
v3x.property/users/1234
v3x.property/items/1234
v3x.property/groups/1234
v3x.property/template/1234
```

entities at these urls have ld+json blobs that contain the entity's data.
IMPORTANT; these blobs may be customized based on the viewer's permissions.
This means that some data may be hidden from the viewer.
If you are running into trouble double check if you are making your request with the correct authorization header.

An example of a tracked item could be:

```json
{
"@context": "https://v3x.property/definitions/item.json",
"@type": "Item",
"id": "https://v3x.property/items/1234",
"data": {
"name": "My Cool Item",
"description": "This is a cool item",
"color": "red"
},
"owner": "https://v3x.property/users/1234",
"created": "2023-06-01T00:00:00Z",
"modified": "2023-06-01T00:00:00Z"
}
```
45 changes: 45 additions & 0 deletions engine/.build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ARG BINARY_NAME_DEFAULT=v3x-property-engine
# ARG MY_GREAT_CONFIG_DEFAULT="someconfig-default-value"

FROM clux/muslrust:stable as builder
RUN groupadd -g 10001 -r dockergrp && useradd -r -g dockergrp -u 10001 dockeruser
ARG BINARY_NAME_DEFAULT
ENV BINARY_NAME=$BINARY_NAME_DEFAULT
# Build the project with target x86_64-unknown-linux-musl

# Build dummy main with the project's Cargo lock and toml
# This is a docker trick in order to avoid downloading and building
# dependencies when lock and toml not is modified.
COPY Cargo.lock .
COPY Cargo.toml .
RUN mkdir src \
&& echo "fn main() {print!(\"Dummy main\");} // dummy file" > src/main.rs
RUN set -x && cargo build --target x86_64-unknown-linux-musl --release
RUN ["/bin/bash", "-c", "set -x && rm target/x86_64-unknown-linux-musl/release/deps/${BINARY_NAME//-/_}*"]

# Now add the rest of the project and build the real main
COPY src ./src
RUN set -x && cargo build --target x86_64-unknown-linux-musl --release
RUN mkdir -p /build-out
RUN set -x && cp target/x86_64-unknown-linux-musl/release/$BINARY_NAME /build-out/

# Create a minimal docker image
FROM scratch

COPY --from=0 /etc/passwd /etc/passwd
USER dockeruser

ARG BINARY_NAME_DEFAULT
ENV BINARY_NAME=$BINARY_NAME_DEFAULT
# ARG MY_GREAT_CONFIG_DEFAULT
# ENV MY_GREAT_CONFIG=$MY_GREAT_CONFIG_DEFAULT

ENV RUST_LOG="error,$BINARY_NAME=info"
COPY --from=builder /build-out/$BINARY_NAME /

EXPOSE 3000

# Start with an execution list (there is no sh in a scratch image)
# No shell => no variable expansion, |, <, >, etc
# Hard coded start command
CMD ["/v3x-property-engine"]
1 change: 1 addition & 0 deletions engine/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/debug
2 changes: 1 addition & 1 deletion engine/Cargo.lock

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

2 changes: 1 addition & 1 deletion engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "v3x-property"
name = "v3x-property-engine"
version = "0.1.0"
edition = "2021"

Expand Down
3 changes: 3 additions & 0 deletions engine/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build:
# cargo build --release
docker buildx build -t ghcr.io/v3xlabs/v3x-property-engine:latest -f .build/Dockerfile .
9 changes: 9 additions & 0 deletions engine/compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# runs the engine on port 3000
version: "3.9"
services:
engine:
build:
context: .
dockerfile: .build/Dockerfile
ports:
- "3000:3000"
7 changes: 7 additions & 0 deletions engine/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# runs the engine on port 3000
version: "3.9"
services:
engine:
image: ghcr.io/v3xlabs/v3x-property-engine:latest
ports:
- "3000:3000"

0 comments on commit 417f471

Please sign in to comment.