-
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.
chore: improve environment handling and docker setup, remove .env val…
…idation (#7) ## Summary This PR includes a series of updates and improvements aimed at refining both the development and production environments: - **Environment Handling**: - Improved environment variable loading and usage within various commands. - Removed the validation check for the `.env` file. This change was necessary because in production environments using Docker, the `.env` file is not utilized, which was causing unnecessary errors. - **Dockerfile Enhancements**: - Improved the Dockerfile to better accommodate both development and production environments, ensuring smoother transitions between these setups. - **App Configuration**: - Updated application settings specifically for the development environment, optimizing for local development workflows. - **CI/CD**: - Added Dependabot configuration for weekly dependency updates, enhancing project maintenance and security. relates to basementdevs/twitch-better-profile#56
- Loading branch information
Showing
12 changed files
with
173 additions
and
78 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
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,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" ] |
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,23 +1,24 @@ | ||
# Rust | ||
RUST_LOG=info | ||
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="8001" | ||
APP_TLS_ENABLED="false" | ||
APP_TLS_CERT="/your/path/to/cert.pem" | ||
APP_TLS_KEY="/your/path/to/key.pem" | ||
APP_PLATFORM_SECRET="secret" | ||
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="host:port" | ||
SCYLLA_NODES=scylla-1:9042 | ||
SCYLLA_USERNAME= | ||
SCYLLA_PASSWORD= | ||
SCYLLA_CACHED_QUERIES="15" | ||
SCYLLA_KEYSPACE="twitch" | ||
SCYLLA_CACHED_QUERIES=15 | ||
SCYLLA_KEYSPACE=twitch |
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,23 +1,24 @@ | ||
# Rust | ||
RUST_LOG=info | ||
RUST_LOG=twitch_extension_api=info | ||
RUST_BACKTRACE=1 | ||
|
||
# Http | ||
MAX_WORKERS=4 | ||
|
||
# App Config | ||
APP_NAME="Twitch Better Chat API" | ||
APP_VERSION="0.1.0" | ||
APP_URL="0.0.0.0" | ||
APP_PORT="8001" | ||
APP_TLS_ENABLED="false" | ||
APP_TLS_CERT="/your/path/to/cert.pem" | ||
APP_TLS_KEY="/your/path/to/key.pem" | ||
APP_PLATFORM_SECRET="secret" | ||
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_NODES=localhost:9042 | ||
SCYLLA_USERNAME= | ||
SCYLLA_PASSWORD= | ||
SCYLLA_CACHED_QUERIES="15" | ||
SCYLLA_KEYSPACE="twitch" | ||
SCYLLA_CACHED_QUERIES=15 | ||
SCYLLA_KEYSPACE=twitch |
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 @@ | ||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
target-branch: "develop" | ||
- package-ecosystem: "cargo" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
target-branch: "develop" |
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
Empty file.
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,23 @@ | ||
services: | ||
tbp-server: | ||
build: | ||
context: . | ||
dockerfile: .docker/Dockerfile.prod | ||
image: tbp-consumer-api:${APP_VERSION} | ||
hostname: prod | ||
restart: on-failure | ||
ports: | ||
- "3001-3003:3000" | ||
deploy: | ||
replicas: 3 | ||
resources: | ||
limits: | ||
cpus: '0.3' | ||
memory: '300MB' | ||
networks: | ||
- tbp-consumer-api | ||
stop_signal: SIGTERM | ||
networks: | ||
tbp-consumer-api: | ||
name: tbp-consumer-api | ||
driver: bridge |
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
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