-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
faa89f1
commit e518822
Showing
9 changed files
with
183 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
MASTER_BACKEND_PORT=1234 | ||
MASTER_BACKEND_HOST=example.com | ||
MASTER_BACKEND_URL=${MASTER_BACKEND_HOST}:${MASTER_BACKEND_PORT} | ||
DATABASE_PORT=5432 | ||
DATABASE_NAME=mydatabase | ||
DATABASE_USER=myuser | ||
DATABASE_PASSWORD=mysecretpassword | ||
DATABASE_HOST=db.example.com | ||
DATABASE_URL=postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME} | ||
JWT_ACCESS_SECRET=myaccesssecret | ||
JWT_REFRESH_SECRET=myrefreshsecret | ||
RUST_ENV=production | ||
LOGGER_URL=http://logs.example.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Build, Test and Deploy to DigitalOcean | ||
|
||
on: | ||
push: | ||
branches: | ||
- production | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: ${{ runner.os }}-cargo- | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
|
||
- name: Build | ||
run: cargo build --release | ||
|
||
- name: Login to GitHub Container Registry | ||
run: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GHCR_PAT }} | ||
|
||
- name: Set ghcr.io url | ||
run: echo "REPO=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}" | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build the Docker image | ||
run: | | ||
docker build . -t ghcr.io/${{ env.REPO }}:${{ github.sha }} | ||
docker tag ghcr.io/${{ env.REPO }}:${{ github.sha }} ghcr.io/${{ env.REPO }}:latest | ||
- name: Push the Docker image | ||
run: | | ||
docker push ghcr.io/${{ env.REPO }}:${{ github.sha }} | ||
docker push ghcr.io/${{ env.REPO }}:latest | ||
# deploy: | ||
# needs: build | ||
# runs-on: ubuntu-latest | ||
|
||
# steps: | ||
# - uses: actions/checkout@v3 | ||
|
||
# - name: Add SSH key | ||
# run: | | ||
# mkdir -p ~/.ssh | ||
# echo "${{ secrets.HELIOS_SSH }}" > ~/.ssh/helios_ssh | ||
# chmod 600 ~/.ssh/helios_ssh | ||
|
||
# - name: Setup to DigitalOcean | ||
# run: | | ||
# ssh -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GHCR_PAT }}" | ||
# ssh -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "rm -f docker-compose.yml" | ||
# scp -i ~/.ssh/helios_ssh -P ${{ secrets.SSH_PORT }} docker-compose.yml ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:~/docker-compose.yml | ||
|
||
# - name: Deploy to DigitalOcean | ||
# run: | | ||
# ssh -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "docker-compose down" | ||
# ssh -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "docker-compose pull" | ||
# ssh -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "docker-compose up -d" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
.env* | ||
.env | ||
.env.production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM clux/muslrust:stable AS chef | ||
ARG MASTER_BACKEND_PORT | ||
RUN cargo install cargo-chef | ||
WORKDIR /master-backend | ||
|
||
FROM chef AS planner | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM chef AS builder | ||
COPY --from=planner /master-backend/recipe.json recipe.json | ||
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json | ||
COPY . . | ||
RUN cargo build --release --target x86_64-unknown-linux-musl | ||
|
||
FROM scratch | ||
COPY --from=builder /master-backend/target/x86_64-unknown-linux-musl/release/helios-master-backend /master-backend | ||
ENTRYPOINT ["/master-backend"] | ||
EXPOSE $MASTER_BACKEND_PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Helios | Rust master backend | ||
|
||
[![AGPL-3.0 License](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://choosealicense.com/licenses/agpl-3.0/) | ||
|
||
Rust implementation of the Helios backend. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: "master-backend" | ||
|
||
services: | ||
master-backend: | ||
build: | ||
context: . | ||
args: | ||
- MASTER_BACKEND_PORT=${MASTER_BACKEND_PORT} | ||
dockerfile: Dockerfile | ||
restart: always | ||
ports: | ||
- "${MASTER_BACKEND_PORT}:${MASTER_BACKEND_PORT}" | ||
depends_on: | ||
- database | ||
|
||
database: | ||
image: postgres:12 | ||
restart: always | ||
environment: | ||
POSTGRES_DB: ${DATABASE_NAME} | ||
POSTGRES_USER: ${DATABASE_USER} | ||
POSTGRES_PASSWORD: ${DATABASE_PASSWORD} | ||
ports: | ||
- "${DATABASE_PORT}:${DATABASE_PORT}" | ||
command: -p ${DATABASE_PORT} | ||
volumes: | ||
- database-volume:/var/lib/postgresql/data | ||
|
||
logger: | ||
image: ghcr.io/heliosshieldproject/logger-rust:latest | ||
restart: always | ||
environment: | ||
- MONGO_URL=${MONGO_URL} | ||
- LOGGER_URI=${LOGGER_URI} | ||
ports: | ||
- "${LOGGER_PORT}:${LOGGER_PORT}" | ||
|
||
logs-database: | ||
image: mongo | ||
restart: always | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: ${LOGS_DATABASE_USER} | ||
MONGO_INITDB_ROOT_PASSWORD: ${LOGS_DATABASE_PASSWORD} | ||
volumes: | ||
- logs-database-volume:/data/db | ||
command: | ||
- --port | ||
- ${LOGS_DATABASE_PORT} | ||
ports: | ||
- "${LOGS_DATABASE_PORT}:${LOGS_DATABASE_PORT}" | ||
|
||
logs-viewer: | ||
image: mongo-express | ||
restart: always | ||
ports: | ||
- ${LOGS_VIEWER_PORT}:8081 | ||
environment: | ||
ME_CONFIG_MONGODB_URL: ${MONGO_URL} | ||
ME_CONFIG_OPTIONS_EDITORTHEME: nord | ||
ME_CONFIG_BASICAUTH_USERNAME: ${LOGS_VIEWER_USER} | ||
ME_CONFIG_BASICAUTH_PASSWORD: ${LOGS_VIEWER_PASSWORD} | ||
depends_on: | ||
- logs-database | ||
|
||
volumes: | ||
database-volume: | ||
logs-database-volume: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters