Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: build service staging #266

Merged
merged 8 commits into from
Mar 19, 2024
Merged
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
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
AWS_REGION="us-east-1"
AWS_KEY="root"
AWS_SECRET="password"
AWS_S3_ENDPOINT="http://minio:9000"
AWS_S3_BUCKET="placeos-drivers-build-service"
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## v4.12.0 (2023-11-21)

### Feat

- PPT-524 Integrate the build service into core ([#262](https://github.com/PlaceOS/core/pull/262))

### Refactor

- details endpoint will retrieve driver defaults instead of metadata ([#264](https://github.com/PlaceOS/core/pull/264))

## v4.11.10 (2023-10-04)

### Fix
Expand Down
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ RUN shards install --production --ignore-crystal-version --skip-postinstall --sk
# Add src
COPY ./src /app/src

RUN shards build exec_from \
--error-trace \
--production

# Build the required target
ENV UNAME_AT_COMPILE_TIME=true

Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ The coordination service for running drivers on [PlaceOS](https://place.technolo

## Implementation

### Cloning

Core handles the cloning of driver repositories.
If a repository is already present on the file system, its git state is adjusted to match the model's commit.

### Compilation

Compilation of drivers is performed on all core nodes.
Compilation of drivers and binary management is performed by `build-api` service.

### Module Management

Expand Down
62 changes: 55 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ x-postgresdb-client-env: &postgresdb-client-env
PG_USER: ${PG_USER:-postgres}
PG_PASSWORD: ${PG_PASSWORD:-password}

x-s3-client-env: &s3-client-env
AWS_REGION: ${AWS_REGION:-"us-east-1"}
AWS_KEY: ${AWS_KEY:-"root"}
AWS_SECRET: ${AWS_SECRET:-"password"}
AWS_S3_ENDPOINT: ${AWS_S3_ENDPOINT:-"http://minio:9000"}
AWS_S3_BUCKET: ${AWS_S3_BUCKET:-"placeos-drivers-build-service"}

x-build-api-env: &build-api-env
BUILD_API_HOST: ${BUILD_API_HOST:-build_service}
BUILD_API_PORT: ${BUILD_API_PORT:-3000}

services:
test: # Module coordinator
image: placeos/service-spec-runner:${CRYSTAL_VERSION:-latest}
Expand All @@ -37,17 +48,14 @@ services:
- redis
- postgres
- migrator
- build_service
security_opt:
- seccomp:unconfined
environment:
# Environment
GITHUB_ACTION: ${GITHUB_ACTION:-}
# Service Hosts
<< : *etcd-client-env
<< : *redis-client-env
<< : *postgresdb-client-env
# Environment
<< : *deployment-env
<<: [*etcd-client-env,*redis-client-env, *postgresdb-client-env,*deployment-env, *build-api-env]

redis:
image: eqalpha/keydb
Expand Down Expand Up @@ -82,8 +90,7 @@ services:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: place_development
ports:
- 5432:5432

migrator:
build:
context: ${PWD}/spec/migration
Expand All @@ -94,3 +101,44 @@ services:
environment:
GITHUB_ACTION: ${GITHUB_ACTION:-}
PG_DATABASE_URL: ${PG_DATABASE_URL:-postgresql://postgres:password@postgres:5432/place_development}

build_service:
image: placeos/build_service:nightly
restart: always
hostname: build_service
depends_on:
- minio
- testbucket
environment:
<<: *s3-client-env

minio:
image: minio/minio:latest
volumes:
- s3:/data
ports:
- 9000:9000
- 9090:9090
environment:
<< : *s3-client-env
MINIO_ROOT_USER: $AWS_KEY
MINIO_ROOT_PASSWORD: $AWS_SECRET
command: server /data --console-address ":9090"

testbucket:
image: minio/mc:latest
depends_on:
- minio
environment:
<< : *s3-client-env
entrypoint: >
sh -c '
sleep 3 &&
mc config host add s3 $AWS_S3_ENDPOINT $AWS_KEY $AWS_SECRET &&
mc mb -p s3/$AWS_S3_BUCKET &&
exit 0
'

volumes:
s3:
driver: local
12 changes: 0 additions & 12 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ shards:
git: https://github.com/crystal-ameba/ameba.git
version: 1.6.1

auto_initialize:
git: https://github.com/kostya/auto_initialize.git
version: 0.1.0

backtracer:
git: https://github.com/sija/backtracer.cr.git
version: 1.2.2
Expand Down Expand Up @@ -85,10 +81,6 @@ shards:
git: https://github.com/crystal-loot/exception_page.git
version: 0.4.1

exec_from:
git: https://github.com/place-labs/exec_from.git
version: 2.0.0

faker:
git: https://github.com/askn/faker.git
version: 0.8.0
Expand Down Expand Up @@ -213,10 +205,6 @@ shards:
git: https://github.com/placeos/calendar.git
version: 4.20.1

placeos-compiler:
git: https://github.com/placeos/compiler.git
version: 4.9.3

placeos-core-client:
git: https://github.com/placeos/core-client.git
version: 0.5.2
Expand Down
17 changes: 4 additions & 13 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
name: placeos-core
version: 4.11.10
version: 4.12.0
crystal: ~> 1.3

targets:
core:
main: src/core-app.cr
edge:
main: src/edge-app.cr
exec_from:
main: lib/exec_from/src/app.cr

dependencies:
action-controller:
Expand Down Expand Up @@ -38,14 +36,6 @@ dependencies:
github: spider-gazelle/log_helper
version: ~> 1

placeos-core-client:
github: placeos/core-client
version: ~> 0.3

placeos-compiler:
github: placeos/compiler
version: ~> 4.9

placeos-driver:
github: placeos/driver
version: ~> 6.1
Expand Down Expand Up @@ -87,8 +77,9 @@ dependencies:
tasker:
github: spider-gazelle/tasker

auto_initialize:
github: kostya/auto_initialize
connect-proxy:
github: spider-gazelle/connect-proxy
version: ~> 2.0

development_dependencies:
ameba:
Expand Down
102 changes: 0 additions & 102 deletions spec/api/drivers_spec.cr

This file was deleted.

8 changes: 3 additions & 5 deletions spec/api/status_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ module PlaceOS::Core::Api

describe "status/" do
it "renders data about node" do
repo, driver, _, resource_manager = create_resources
_, driver, _, resource_manager = create_resources

driver.reload!

binary = Compiler.executable_name(driver.file_name, driver.commit, driver.id.as(String))
response = client.get(namespace, headers: json_headers)
response.status_code.should eq 200

status = Core::Client::CoreStatus.from_json(response.body)
status = Status::Statistics.from_json(response.body)

status.compiled_drivers.should contain binary
status.available_repositories.should contain repo.folder_name
status.compiled_drivers.should_not be_empty

status.run_count.local.modules.should eq 0
status.run_count.local.drivers.should eq 0
Expand Down
Loading
Loading