Skip to content

Commit

Permalink
Merge pull request #1 from infracloudio/rust-app
Browse files Browse the repository at this point in the history
Rust app
  • Loading branch information
samkulkarni20 authored Dec 4, 2023
2 parents 2fc08a4 + f44b8e1 commit ddeb820
Show file tree
Hide file tree
Showing 44 changed files with 5,566 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish Acorn image
on:
workflow_dispatch:
push:
tags:
- "v[0-9]*"

jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: acorn-io/actions-setup@v2
with:
acorn-version: "main"
- name: Login to GHCR
uses: acorn-io/actions-login@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Publish with signature
run: |
TAG=${GITHUB_REF#refs/*/}
acorn build --platform linux/amd64 --platform linux/arm64 --push -t ghcr.io/infracloudio/rust-acorn:${TAG} .
55 changes: 55 additions & 0 deletions Acornfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "Rust Sample Acorn"
description: "Acorn running a sample Rust app"
readme: "./README.md"
icon: "./rust_icon.png"


args: {
// Name of the database to create. Defaults to "rust-sqlx"
dbName: "rust-sqlx"
// Name of the database user to create. Defaults to "rust"
dbUser: "rust"
}

services: db: {
image: "ghcr.io/acorn-io/postgres:v15.#-#"
serviceArgs: {
dbName: args.dbName
dbUser: args.dbUser
}
}

containers: {
backend: {
image: "ghcr.io/infracloudio/rust-backend:v2"
env: {
"POSTGRES_HOST": "@{service.db.address}"
"POSTGRES_PORT": "@{service.db.port.5432}"
"POSTGRES_USER": "@{service.db.secrets.admin.username}"
"POSTGRES_PASSWORD":"@{service.db.secrets.admin.password}"
"POSTGRES_DB":"@{service.db.data.dbName}"
"DATABASE_URL":"postgresql://@{service.db.secrets.admin.username}:@{service.db.secrets.admin.password}@@{service.db.address}:5432/@{service.db.data.dbName}?schema=public"
"PGADMIN_DEFAULT_EMAIL":"[email protected]"
"PGADMIN_DEFAULT_PASSWORD":"password123"
}
ports: {
publish: "8000:8000/http"
}
memory: 1048Mi
consumes: ["db"]
}
frontend: {
image: "ghcr.io/infracloudio/rust-frontend:v1"
cmd: ["/bin/sh", "-c", "cd /usr/src/fullstack-rust-app/frontend && BACKEND_SERVER=$BACKEND_SERVER trunk serve --address 0.0.0.0 --port 3000"]
ports: {
publish: "3000:3000/http"
}
env: {
// Frontend forwards the requests to the Backend Container Service Endpoint
"BACKEND_SERVER": "@{services.backend.endpoint}"
}
memory: 1048Mi
dependsOn: ["backend"]
}
}

10 changes: 10 additions & 0 deletions Dockerfile.backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM rust:1.73-slim-bullseye

RUN apt --yes update && apt --yes install git pkg-config curl libssl-dev ca-certificates curl gnupg
RUN cargo install wasm-bindgen-cli sqlx-cli
RUN rustup target add wasm32-unknown-unknown

WORKDIR /usr/src/
COPY . .

ENTRYPOINT ["/bin/sh", "-c", "cd /usr/src/fullstack-rust-app/backend && sqlx migrate run; cargo run --bin backend -- --port 8000"]
13 changes: 13 additions & 0 deletions Dockerfile.frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM rust:1.73-slim-bullseye

RUN apt --yes update && apt --yes install git pkg-config curl libssl-dev ca-certificates curl gnupg
RUN cargo install trunk wasm-bindgen-cli
RUN rustup target add wasm32-unknown-unknown

WORKDIR /usr/src/
COPY . .

RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y nodejs

RUN npx tailwindcss-cli@latest
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Acorn for a Rust sample app - Feedback App

This is a Fullstack Rust app created in using Actix, SQLX and Postgres as Backend and Yew-TailwindCSS as its frontend. The user can provide feedback ratings and comments using this SPA web app. The application utilises the Acorn Postgres DB service to store the feedback data where the dbName and dbUser are customisable. Once deployed, the SPA web app is available on the Frontend Service Endpoint.


## What is Rust?

Rust has been Stack Overflow's most loved language for four years in a row and rightfully so. Rust is a blazing fast and memory-efficient static compiled language with a rich type system and ownership model. It can be used to power performance-critical services while guaranteeing memory-safety and thread-safety, empowering developers to debug at compile-time.


1 change: 1 addition & 0 deletions fullstack-rust-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading

0 comments on commit ddeb820

Please sign in to comment.