Skip to content

Commit

Permalink
release: twitch better profile 0.2.0 (#9)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Boll <danielboll.academico@gmail.com>
Co-authored-by: Gabriel do Carmo Vieira <gabrielcarmovieira16@gmail.com>
Co-authored-by: Daniel Boll <43689101+Daniel-Boll@users.noreply.github.com>
Co-authored-by: Gabriel do Carmo Vieira <48625433+gvieira18@users.noreply.github.com>
  • Loading branch information
4 people authored Sep 28, 2024
1 parent e10e463 commit 3b946c4
Show file tree
Hide file tree
Showing 51 changed files with 1,346 additions and 486 deletions.
35 changes: 35 additions & 0 deletions .docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# rust:1.80.1-alpine3.20
FROM rust@sha256:1f5aff501e02c1384ec61bb47f89e3eebf60e287e6ed5d1c598077afc82e83d5 AS dev

ARG INIT_PATH=/usr/local/bin/dumb-init
ARG INIT_URL=https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_x86_64
ARG USER=rust
ARG USER_UID=1000
ARG USER_GID=${USER_UID}
ARG WORK_DIR=/usr/src/app

ENV TZ=America/Sao_Paulo TERM=xterm-256color LANG=C.UTF-8 LC_ALL=C.UTF-8

RUN set -euxo pipefail; \
apk add --no-cache nano sudo build-base tzdata curl cmake g++ pcre-dev openssl-dev make gmp-dev git ca-certificates wget zip unzip busybox; \
curl --fail --silent --show-error --location ${INIT_URL} --output ${INIT_PATH}; \
chmod +x ${INIT_PATH}; \
cargo install cargo-watch;

RUN set -euxo pipefail; \
addgroup -g ${USER_GID} ${USER}; \
adduser -u ${USER_UID} -G ${USER} -h /home/${USER} -D ${USER}; \
echo "${USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USER}; \
chmod 0440 /etc/sudoers.d/${USER};

USER ${USER}

ENV CARGO_HOME="/home/${USER}/.cargo"

WORKDIR ${WORK_DIR}

EXPOSE 3000

ENTRYPOINT [ "/usr/local/bin/dumb-init", "--" ]

CMD [ "cargo", "watch", "-w", "src", "-x", "run" ]
66 changes: 66 additions & 0 deletions .docker/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
ARG INIT_PATH=/usr/local/bin/dumb-init
ARG INIT_URL=https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_x86_64
ARG USER=rust
ARG USER_UID=1000
ARG USER_GID=${USER_UID}
ARG WORK_DIR=/usr/src/app

# rust:1.80.1-alpine3.20
FROM rust@sha256:1f5aff501e02c1384ec61bb47f89e3eebf60e287e6ed5d1c598077afc82e83d5 AS builder

ARG INIT_PATH
ARG INIT_URL
ARG USER
ARG USER_UID
ARG USER_GID
ARG WORK_DIR

ENV CI=true LANG=C.UTF-8 LC_ALL=C.UTF-8

WORKDIR ${WORK_DIR}

RUN set -euxo pipefail; \
apk add --no-cache build-base cmake g++ pcre-dev openssl-dev gmp-dev curl ca-certificates; \
curl --fail --silent --show-error --location ${INIT_URL} --output ${INIT_PATH}; \
chmod +x ${INIT_PATH};

COPY Cargo.toml Cargo.lock Makefile ${WORK_DIR}/
COPY src ${WORK_DIR}/src

RUN set -euxo pipefail; \
make clean; \
make release;

# alpine:3.20
FROM alpine@sha256:0a4eaa0eecf5f8c050e5bba433f58c052be7587ee8af3e8b3910ef9ab5fbe9f5 AS main

ARG INIT_PATH
ARG INIT_URL
ARG USER
ARG USER_UID
ARG USER_GID
ARG WORK_DIR

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

RUN set -euxo pipefail; \
addgroup -g ${USER_GID} ${USER}; \
adduser -u ${USER_UID} -G ${USER} -D ${USER}; \
apk update --no-cache; \
apk upgrade --no-cache;

COPY --from=builder --chown=${USER}:${USER} ${INIT_PATH} ${INIT_PATH}

WORKDIR ${WORK_DIR}

COPY --from=builder --chown=${USER}:${USER} ${WORK_DIR}/target/release/twitch-extension-api ${WORK_DIR}/twitch-extension-api

COPY --chown=${USER}:${USER} static ${WORK_DIR}/static

USER ${USER}

EXPOSE 3000

ENTRYPOINT [ "/usr/local/bin/dumb-init", "--" ]

CMD [ "/usr/src/app/twitch-extension-api" ]
23 changes: 23 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Exclude version control and IDE files
.git
.github
.idea

# Exclude build artifacts
target

# Exclude environment files
.env*

# Exclude Docker development files
.docker*

# Exclude certificate files
cert.pem
key.pem

# Exclude unnecessary documentation and configuration
README.md

# Exclute test files
tests
29 changes: 29 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
# Adapted from rust-lang/rust repository

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.rs]
max_line_length = 100

[*.md]
# double whitespace at end of line
# denotes a line break in Markdown
trim_trailing_whitespace = false

[*.yml]
indent_size = 2

[Makefile]
indent_style = tab
indent_size = 4
15 changes: 0 additions & 15 deletions .env

This file was deleted.

24 changes: 24 additions & 0 deletions .env.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Rust
RUST_LOG=twitch_extension_api=debug
RUST_BACKTRACE=1

# Http
MAX_WORKERS=2

# App Config
APP_NAME="Twitch Better Chat API"
APP_VERSION=0.1.0
APP_URL=0.0.0.0
APP_PORT=3000
APP_ENV=dev
APP_TLS_ENABLED=false
APP_TLS_CERT=/your/path/to/cert.pem
APP_TLS_KEY=/your/path/to/key.pem
APP_PLATFORM_SECRET=secret

# Database Config
SCYLLA_NODES=scylla-1:9042
SCYLLA_USERNAME=
SCYLLA_PASSWORD=
SCYLLA_CACHED_QUERIES=15
SCYLLA_KEYSPACE=twitch
32 changes: 21 additions & 11 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# Rust
RUST_LOG=twitch_extension_api=info
RUST_BACKTRACE=1

# Http
MAX_WORKERS=4

# App Config
APP_NAME="Gaming Leaderboard"
APP_VERSION="0.0.1"
APP_URL="0.0.0.0"
APP_PORT="8000"
APP_AUTH_CERT="/home/danielhe4rt/dev/scylladb/browser-extension/api/cert.pem"
APP_AUTH_KEY="/home/danielhe4rt/dev/scylladb/browser-extension/api/key.pem"
APP_NAME='Twitch Better Chat API'
APP_VERSION=0.1.0
APP_URL=0.0.0.0
APP_PORT=3000
APP_ENV=dev
APP_TLS_ENABLED=false
APP_TLS_CERT=/your/path/to/cert.pem
APP_TLS_KEY=/your/path/to/key.pem
APP_PLATFORM_SECRET=secret

# Database Config
SCYLLA_NODES="localhost:9042"
SCYLLA_USERNAME="scylla"
SCYLLA_PASSWORD=""
SCYLLA_CACHED_QUERIES="15"
SCYLLA_KEYSPACE="twitch"
SCYLLA_NODES=localhost:9042
SCYLLA_USERNAME=
SCYLLA_PASSWORD=
SCYLLA_CACHED_QUERIES=15
SCYLLA_KEYSPACE=twitch
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2

updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
target-branch: "develop"
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
target-branch: "develop"
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
setup:
name: Setup rust
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup rust
uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
components: clippy, rustfmt
- name: Build project
run: make build
lint:
name: Run lint and format
runs-on: ubuntu-24.04
env:
RUSTFLAGS: "-Dwarnings"
needs:
- setup
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup rust
uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
components: clippy, rustfmt
- name: Run formatter
uses: actions-rust-lang/rustfmt@2d1d4e9f72379428552fa1def0b898733fb8472d # v1.1.0
- name: Run linter
uses: clechasseur/rs-clippy-check@a2a93bdcf05de7909aabd62eca762179ad3dbe50 # v3.0.5
with:
args: --all-features
Loading

0 comments on commit 3b946c4

Please sign in to comment.