Skip to content

Commit

Permalink
feat: Move env vars/secrets into separate directory
Browse files Browse the repository at this point in the history
  • Loading branch information
nezort11 committed Jan 4, 2025
1 parent bfa923c commit 910ca75
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
6 changes: 4 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.git
.env
.env.example
.github
node_modules
Dockerfile
compose.yml

# Environment variables/secrets
# (storing environment files inside a Docker image is generally not recommended)
./env
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,21 @@ jobs:
- name: Deploy Serverless Container
id: deploy-sls-container
# https://yandex.cloud/en/docs/cli/cli-ref/serverless/cli-ref/container/revision/deploy
uses: yc-actions/yc-sls-container-deploy@v2
# https://github.com/yc-actions/yc-sls-container-deploy/blob/main/action.yml
with:
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
revision-service-account-id: ${{ vars.SERVICE_ACCOUNT_ID }}
revision-image-url: ${{ env.IMAGE_NAME }}
container-name: ${{ vars.CONTAINER_NAME }}
folder-id: ${{ vars.FOLDER_ID }}
revision-cores: 1
revision-memory: 2048Mb
revision-memory: 2048Mb # Mb/Gb
# revision-core-fraction: 100
revision-concurrency: 3
revision-execution-timeout: 60
revision-execution-timeout: 180 # seconds
revision-storage-mounts: "${{ vars.ENV_BUCKET_NAME }}:/app/env:read-only"

# steps:
# - name: Connect to remote server via SSH
Expand Down
7 changes: 2 additions & 5 deletions .env.example → env/.env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
ENV_FILE_LOADED=true

CONTAINER_NUMBER=""

# https://github.com/FOSWLY/vot-cli/blob/main/src/config/config.js
# EXPIRES AFTER SOME TIME
YANDEX_TRANSLATE_HMAC_SHA254_SECRET=""
# TODO: refactor to automatically export and import micro service deploy artifacts
VIDEO_TRANSLATE_API_URL=".../translate"

BOT_TOKEN_PROD=""
BOT_TOKEN_DEV=""
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const getVideoDurationInSeconds: any = {};
// const ytdl: any = {};

const COOKIES_FILENAME = "cookies.json";
const COOKIES_FILE_PATH = path.join(__dirname, "..", COOKIES_FILENAME);
const COOKIES_FILE_PATH = path.join(__dirname, "..", "env", COOKIES_FILENAME);

console.log("cookiesFilePath", COOKIES_FILE_PATH);

Expand Down
2 changes: 1 addition & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const setIsPublic = (isPublic: boolean) => (IS_PUBLIC = isPublic);

// otherwise loaded automatically by docker
if (process.env.ENV_FILE_LOADED !== "true") {
dotenv.config({ path: "./.env" }); // mutates process.env from .env
dotenv.config({ path: "./env/.env" }); // mutates process.env from .env
}

// Dynamically loaded env variables
Expand Down

0 comments on commit 910ca75

Please sign in to comment.