Initial check-in for all existing scripts, launch.sh, init_devbox.sh, etc.

This commit is contained in:
jetli 2024-12-12 05:39:39 +00:00
commit 4a60373e2d
36 changed files with 1277 additions and 0 deletions

View File

@ -0,0 +1 @@
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlBWRTc6SVM2RzpRUEVJOkpFRTc6TkgzVDpTNEhaOk5IRko6U1BTSzpWQks0OjRCSEI6V01DTjpSSUdXIn0.eyJqdGkiOiI1MDIzMjVjOS1jZDE4LTRjMGMtOWRjOS1hMmI1ZjQ3OWU5NDYiLCJzdWIiOiJqZXRsaUBmcmVlbGVhcHMuY29tIiwibmJmIjoxNzMwMDgxODE4LCJleHAiOjE3MzAwOTM1MTgsImlhdCI6MTczMDA4MTgxOCwiaXNzIjoiQXp1cmUgQ29udGFpbmVyIFJlZ2lzdHJ5IiwiYXVkIjoiZnJlZWxlYXBzLmF6dXJlY3IuaW8iLCJ2ZXJzaW9uIjoiMS4wIiwicmlkIjoiYjYyOGFhNDNmYTFlNDQzMzlmN2YxYTA0OWViZWM1ZmQiLCJncmFudF90eXBlIjoicmVmcmVzaF90b2tlbiIsImFwcGlkIjoiMDRiMDc3OTUtOGRkYi00NjFhLWJiZWUtMDJmOWUxYmY3YjQ2IiwidGVuYW50IjoiY2YxNTFlZTgtNWMyYy00ZmU3LWExYzQtODA5YmE0M2M5ZjI0IiwicGVybWlzc2lvbnMiOnsiYWN0aW9ucyI6WyJyZWFkIiwid3JpdGUiLCJkZWxldGUiLCJtZXRhZGF0YS9yZWFkIiwibWV0YWRhdGEvd3JpdGUiLCJkZWxldGVkL3JlYWQiLCJkZWxldGVkL3Jlc3RvcmUvYWN0aW9uIl19LCJyb2xlcyI6W119.ZAzPIEeoHI00IdmvT1EiPjU-6C3HbRqeTK2iEm6Qh6rZ-iKIqWXmbVP4ncxkjyctGD2TAaaZYatvoYKsgiM7uIfONFldXjWMNVsO1tNeWMI9Wm0n7QEIylh1GBQ0Zj-dKlxd8arrs6Yab-k4x5nIcu4pphXOh8_fF4uV0KcHsznjyFZPDJEOyHhLX5KsQslYjL8DihSc1y_dtlBVbpJhCrde-bwr8KN7xf7Jx0FDFk4MZtjHA-JtvOyJ00oLz0NifhbXYLzXL1imAALFV6P1dXIh1wADwn3_oR7HDC3oLmyp7358qqjdNPUg29HkJbkhvL7JvN0TK6kTIJ-YRVotUQ

View File

@ -0,0 +1,19 @@
export MONGODB_NAME=freeleaps2
export MONGODB_URI=mongodb://localhost:27017/
export SITE_ACCESS_PORT=80
export FREELEAPS_ENV=dev
export STRIPE_API_KEY=sk_test_51Ogsw5B0IyqaSJBrwczlr820jnmvA1qQQGoLZ2XxOsIzikpmXo4pRLjw4XVMTEBR8DdVTYySiAv1XX53Zv5xqynF00GfMqttFd
export STRIPE_WEBHOOK_SECRET=
export SITE_URL_ROOT=http://localhost/
export RABBITMQ_HOST=localhost
export RABBITMQ_PORT=5672
export FONTAWESOME_AUTH_TOKEN=58624E90-2685-43C6-BF0F-0BFECCE11CD2
export FREELEAPS_FREEDEV_ACR_PULL_TOKEN='MG/kAjmmUoVi3EUPruatrqh104pq3d6gtgwMI/FaWT+ACRCZuqtp'
export FREELEAPS_DEVSVC_ENDPOINT=http://localhost:8007/api/devsvc
export FREELEAPS_CONTENT_ENDPOINT=http://localhost:8013/api/content/
export FREELEAPS_CENTRAL_STORAGE_ENDPOINT=http://localhost:8005/api/central_storage/
export FREELEAPS_AUTHENTICATION_ENDPOINT=https://localhost:8004/api/auth/
export JWT_SECRET_KEY=ea84edf152976b2fcec12b78aa8e45bc26a5cf0ef61bf16f5c317ae33b3fd8b0
export FREELEAPS_AUTHENTICATION_ENDPOINT=http://localhost:8004/api/auth/
export EMAIL_FROM=freeleaps@freeleaps.com

View File

@ -0,0 +1,96 @@
FROM ubuntu:22.04
ARG USER_NAME="freedev"
ENV DEBIAN_FRONTEND=noninteractive
# upgrade and install basic tools
RUN apt-get update && \
apt-get install -y --no-install-recommends \
sudo \
openssh-server \
jq \
vim \
git \
python3.10 \
python3-pip \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release \
nginx \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
mkdir /var/run/sshd
# install Node.js and npm
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - && \
apt-get install -y --no-install-recommends nodejs && \
rm -rf /var/lib/apt/lists/*
# install Docker
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
apt-get update && \
apt-get install -y --no-install-recommends docker-ce docker-ce-cli containerd.io && \
apt-get install docker-compose-plugin && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# install Docker Compose
RUN curl -L "https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose
# config SSH
RUN sed -i 's/#ClientAliveInterval 0/ClientAliveInterval 60/' /etc/ssh/sshd_config && \
sed -i 's/#ClientAliveCountMax 3/ClientAliveCountMax 5/' /etc/ssh/sshd_config && \
sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config
# expose SSH port
EXPOSE 22
# copy entrypoint.sh
COPY entrypoint.sh entrypoint_restore.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/entrypoint_restore.sh
# set python3 as default python
RUN ln -s /usr/bin/python3 /usr/bin/python
# copy devbox files
RUN mkdir -p /opt/devbox/ /mnt/docker_data/ /mnt/freeleaps/
COPY requirements.txt /opt/devbox/requirements.txt
COPY acr_login.sh start_all_svc.sh stop_all_svc.sh init_devbox.sh start_backend.sh start_frontend.sh start_frontend_cn.sh gitea_data_backup.tar.gz .dev.env docker-compose.dev.yaml docker-compose.dev.arm64.yaml /opt/devbox/
RUN chmod +x /opt/devbox/*.sh && \
pip3 install --no-cache-dir --upgrade pip && \
pip3 install --no-cache-dir -r /opt/devbox/requirements.txt
RUN useradd -m -s /bin/bash ${USER_NAME} && \
echo "${USER_NAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
usermod -aG docker ${USER_NAME} && \
usermod --password $(echo "${USER_NAME}" | openssl passwd -1 -stdin) ${USER_NAME} && \
ln -s /opt/devbox /home/${USER_NAME}/devbox && \
ln -s /mnt/freeleaps /home/${USER_NAME}/freeleaps && \
chown -R "${USER_NAME}":"${USER_NAME}" /opt/devbox /mnt/freeleaps /home/${USER_NAME}/devbox /home/${USER_NAME}/freeleaps
# install Azure CLI
RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null && \
echo "deb [arch=$(dpkg --print-architecture)] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/azure-cli.list && \
apt-get update && \
apt-get install -y azure-cli
# Copy SSH authorized keys and set permissions
RUN mkdir -p /home/${USER_NAME}/.ssh
COPY authorized_keys /home/${USER_NAME}/.ssh/authorized_keys
RUN chown -R "${USER_NAME}":"${USER_NAME}" /home/${USER_NAME}/.ssh && \
chmod 700 /home/${USER_NAME}/.ssh && \
chmod 600 /home/${USER_NAME}/.ssh/authorized_keys
RUN npm install -g @apollo/client @popperjs/core @vue/apollo-composable axios bootstrap buffer echarts graphql graphql-tag pdfjs-dist pinia vue vue-echarts vue-i18n vue-router vuex @rushstack/eslint-patch @vitejs/plugin-vue @vue/eslint-config-prettier eslint eslint-plugin-vue fast-glob prettier sass sass-loader vite vite-plugin-svg-icons webpack || true
# start
CMD ["/usr/local/bin/entrypoint.sh"]

View File

@ -0,0 +1,72 @@
For Apple Chip:
- Choose
![latest:multi](image.png)
- Your local devbox will look like:
![devbox_v3:latest-multi](image-1.png)
In order to use the latest:multi, update the launch.sh (the repo you got from: https://freeleaps.com:3443/freeleaps/freeleaps-pub.git) to use latest:multi instead of latest when pulling image
Issues you may run into aside from following instructions from doc: https://netorgft10898514.sharepoint.com/:w:/r/sites/CoreEngineering/_layouts/15/Doc.aspx?sourcedoc=%7BC6FE820D-FD5B-40CC-AD47-BB8691B3BC39%7D&file=Freeleaps%20Local%20DevBox%20Usage.docx&action=default&mobileredirect=true
acr_login - you may need to re-run this on your devbox_local docker.
And acr_login may not work on Mac:
```
freedev@ca42ea8db43f:~/devbox$ ./acr_login.sh
rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2
/usr/bin/az: line 3: 725 Trace/breakpoint trap AZ_INSTALLER=DEB "$bin_dir"/../../opt/az/bin/python3 -Im azure.cli "$@"
rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2
/usr/bin/az: line 3: 729 Trace/breakpoint trap AZ_INSTALLER=DEB "$bin_dir"/../../opt/az/bin/python3 -Im azure.cli "$@"
Error: Cannot perform an interactive login from a non TTY device
```
Then, you need to:
```
az ad sp create-for-rbac --name <service-principal-name> --role contributor --scopes /subscriptions/<subscription-id>
```
and:
```
export AZURE_CLIENT_ID=<appId>
export AZURE_SECRET=<password>
export AZURE_TENANT_ID=<tenant>
az login --service-principal --username "$AZURE_CLIENT_ID" --password "$AZURE_SECRET" --tenant "$AZURE_TENANT_ID"
```
QEMU Emulation doesn't work for me
```
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
```
Best practice:
Opening 2 VS Code IDE, one for devbox, one for freeleaps code
Devbox for starting backend/frontend
Freeleaps for coding
Once you started all required containers inside devbox_local, you shall see something like:
```
root@ca42ea8db43f:/# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3b10657107cb mongo:4.4 "docker-entrypoint.s…" 51 minutes ago Up 51 minutes 0.0.0.0:27017->27017/tcp, :::27017->27017/tcp freeleaps2-mongodb
d8327a3717d1 freeleaps.azurecr.io/rabbitmq:3.13 "docker-entrypoint.s…" 59 minutes ago Up 58 minutes 4369/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp freeleaps2-rabbitmq
b0f82d5d1772 freeleaps.azurecr.io/gitea:1.20.4 "/usr/bin/entrypoint…" 59 minutes ago Up 59 minutes 22/tcp, 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp
```
Explanation on the set up v.s. local docker
freeleaps2-backend and freeleaps2-frontend are managed differently than the dependency containers (like gitea, mongo, and rabbitmq).
Key Differences in the Setup
1. Dependency Containers (gitea, mongo, rabbitmq):
• These services are started and managed using Docker Compose within the devbox_v3 container. They operate independently and need to be running in the background to support the backend application.
2. Backend and Frontend Code Execution:
• The init_devbox.sh script clones the code for freeleaps2-backend and freeleaps2-frontend into the local directory within the devbox_v3 container.
• Rather than running in isolated containers, the backend (uvicorn) and frontend are directly executed as processes within the devbox_v3 container itself.
3. Direct Execution Inside devbox_v3:
• By running the backend and frontend code directly inside devbox_v3, you avoid the need for additional containers for each of these services. It simplifies local development by consolidating everything into a single container environment.
4. Docker Compose for Dependencies Only:
• docker-compose.dev.yaml is used to manage only the core dependencies (like gitea, mongodb, rabbitmq), which are treated as separate containers. Future dependencies will be added there.
freeleaps2-backend and freeleaps2-frontend dont spin up as containers. Instead, they run as processes within devbox_v3, using the shared environment provided by that container.
Benefits
• Simplified Container Management: By keeping freeleaps2-backend and freeleaps2-frontend as processes in devbox_v3, we avoid - container-to-container communication and reduce the complexity of managing multiple Docker containers.
• Ease of Development: Such backend and frontend files in a unified environment will be just Freeleaps App, this allows for quicker iteration without rebuilding separate containers.

View File

@ -0,0 +1,5 @@
#!/bin/bash
az login --use-device-code
FREELEAPS_ACR_TOKEN=$(az acr login --name freeleaps --expose-token --output tsv --query accessToken)
docker login freeleaps.azurecr.io --username 00000000-0000-0000-0000-000000000000 --password-stdin <<< $FREELEAPS_ACR_TOKEN
echo $FREELEAPS_ACR_TOKEN > .acr_token

View File

@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDisvXsJbsD8WT/EyFGcwIyo+H3spAn0/lnwnWz8pxbbSYam2bjjZQ+qs4gf2IqFQDsMHcoJ7DRZmGgIKEDg8vP3OlbpeLCTYSotM5eHTX7xpF3Gk659obFNYNAK/zFCT8vGqKz1v6vx/QwH5Nu+v7YB67acDS5rwOiaw4epZL/3X0zB4S51siFS4hFcjsCPCz1vK5I1TsI1bDl3A+spp0qPJ2jE8iYs7hn0nwPRYGEHLiPYBYSKCR4ztQc4YqJ9Gj0+vI0YV4g5zK0EJJVCqPcg4kh0SbBFeVa8UGI5SyyDIIsGA421rlZTLNbjYFv3DjC7zQbP8iqdz1RGRwVr2Qfh50fth1tlyJOosJ4iVX9VnMyS7+BGbtW4wXgS9pOtyZyoD/ARh8qo5lbmwFfbl1r/5LRk/xYltiJ6DJc8QXuIr3uJUGaXJdoM54qh+9payujshN51JSijF6volfdSggEuUJ7ZV8ynN6RXZ1cGBtIAohoCmaoSC/PfreESKPryu0= freedev@a37e35dcdf07

View File

@ -0,0 +1,66 @@
pipeline {
agent {
label 'jenkins-agent'
}
environment {
REGISTRY = 'freeleaps.azurecr.io'
IMAGE_NAME = 'devbox_v3'
LINUX_ARM64_IMAGE_TAG = 'latest-linux-arm64'
LINUX_AMD64_IMAGE_TAG = 'latest-linux-amd64'
}
stages {
stage('Checkout Repository') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '*/main']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
userRemoteConfigs: [[
credentialsId: "git_freeleaps_int",
url: "https://dev.azure.com/freeleaps/freeleaps-int/_git/freeleaps-int"
]]
])
}
}
stage('Docker Login') {
steps {
withCredentials([usernamePassword(credentialsId: 'acr_devops_user',
usernameVariable: 'DOCKER_USERNAME',
passwordVariable: 'DOCKER_PASSWORD')]) {
sh "docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD} ${REGISTRY}"
}
}
}
stage('Set up Docker Buildx') {
steps {
sh '''
# Create and use a new buildx builder
docker buildx rm mybuilder || true
docker buildx create --name mybuilder --use
docker buildx inspect --bootstrap
'''
}
}
stage('Build Multi-Architecture Docker Image') {
steps {
dir("${env.WORKSPACE}/devops/devbox.local/") {
sh "pwd"
// Build multi-architecture image for amd64 and arm64
sh "docker buildx build --build-arg ARCH=amd64 --platform linux/amd64 -t ${REGISTRY}/${IMAGE_NAME}:${LINUX_AMD64_IMAGE_TAG} --push ."
sh "docker buildx build --build-arg ARCH=arm64 --platform linux/arm64 -t ${REGISTRY}/${IMAGE_NAME}:${LINUX_ARM64_IMAGE_TAG} --push ."
}
}
}
}
post {
success {
echo 'Docker image built and pushed successfully.'
}
failure {
echo 'Pipeline failed. Please check the logs for details.'
}
}
}

View File

@ -0,0 +1,20 @@
#!/bin/bash
export CONTAINER_NAME="devbox_local"
if docker ps -a --format '{{.Names}}' | grep -q ^${CONTAINER_NAME}$; then
echo "Docker container '${CONTAINER_NAME}' exists."
if docker ps --format '{{.Names}}' | grep -q ^${CONTAINER_NAME}$; then
echo "Container '${CONTAINER_NAME}' is running. Stopping it..."
docker stop ${CONTAINER_NAME}
echo "Container '${CONTAINER_NAME}' has been stopped."
else
echo "Container '${CONTAINER_NAME}' is not running."
fi
echo "Removing container '${CONTAINER_NAME}'..."
docker rm ${CONTAINER_NAME}
echo "Container '${CONTAINER_NAME}' has been removed."
else
echo "Docker container '${CONTAINER_NAME}' does not exist."
fi

View File

@ -0,0 +1,221 @@
services:
gitea:
# For apple chip, add: platform: linux/amd64
container_name: freeleaps2-gitea
platform: linux/arm64
image: freeleaps.azurecr.io/gitea:latest-linux-arm64
restart: always
ports:
- "3000:3000"
environment:
- DISABLE_REGISTRATION=true
- REQUIRE_SIGNIN_VIEW=true
volumes:
- freeleaps2-gitea-data:/data
networks:
- devbox_freeleaps2-network
mongodb:
# For apple chip, add: platform: linux/amd64
# For apple chip, you may want to downgrade to public mongo:4.4 for log support
container_name: freeleaps2-mongodb
platform: linux/arm64
image: freeleaps.azurecr.io/mongo:latest-linux-arm64
restart: always
ports:
- "27017:27017"
volumes:
- freeleaps2-mongodb-data:/data/db
networks:
- devbox_freeleaps2-network
rabbitmq:
# For apple chip, add: platform: linux/amd64
platform: linux/arm64
container_name: freeleaps2-rabbitmq
image: freeleaps.azurecr.io/rabbitmq:latest-linux-arm64
restart: always
ports:
- "5672:5672"
- "15672:15672"
volumes:
- freeleaps2-rabbitmq-data:/var/lib/rabbitmq
networks:
- devbox_freeleaps2-network
devsvc:
container_name: devsvc
image: freeleaps.azurecr.io/devsvc:1.0.0
restart: always
environment:
- APP_NAME=devsvc
- SERVICE_API_ACCESS_HOST=localhost
- SERVICE_API_ACCESS_PORT=8007
- MONGODB_NAME=freeleaps2
- MONGODB_URI=mongodb://freeleaps2-mongodb:27017/
- GITEA_TOKEN=6786dc398b77d2a9c454b1943019425049deb667
- GITEA_URL=http://freeleaps2-gitea:3000
- CODE_DEPOT_HTTP_PORT=3443
- CODE_DEPOT_SSH_PORT=22
- CODE_DEPOT_DOMAIN_NAME=localhost
- RABBITMQ_HOST=freeleaps2-rabbitmq
- RABBITMQ_PORT=5672
- LOG_BASE_PATH=/app/log/devsvc
- BACKEND_LOG_FILE_NAME=devsvc.log
- APPLICATION_ACTIVITY_LOG=devsvc-application.log
ports:
- 8007:8007
command:
- /bin/sh
- -c
- |
uvicorn webapi.main:app --reload --port=8007 --host=0.0.0.0
volumes:
- type: bind
source: /var/lib/docker/app/devsvc/log
target: /app/log/devsvc
networks:
- devbox_freeleaps2-network
central_storage:
container_name: central_storage
image: freeleaps.azurecr.io/central_storage:latest-linux-arm64
# profiles: [ prod, alpha, dev ]
platform: linux/arm64
restart: always
environment:
- APP_NAME=central_storage
- MONGODB_NAME=freeleaps2
- MONGODB_PORT=27017
- MONGODB_URI=mongodb://freeleaps2-mongodb:27017/
- SERVICE_API_ACCESS_HOST=localhost
- SERVICE_API_ACCESS_PORT=8005
- AZURE_STORAGE_DOCUMENT_API_KEY=xbiFtFeQ6v5dozgVM99fZ9huUomL7QcLu6s0y8zYHtIXZ8XdneKDMcg4liQr/9oNlVoRFcZhWjLY+ASt9cjICQ==
- AZURE_STORAGE_DOCUMENT_API_ENDPOINT=https://freeleaps1document.blob.core.windows.net/
- LOG_BASE_PATH=/app/log/central_storage
- BACKEND_LOG_FILE_NAME=central_storage.log
- APPLICATION_ACTIVITY_LOG=central_storage-application.log
ports:
- 8005:8005
command:
- /bin/sh
- -c
- |
uvicorn webapi.main:app --reload --port=8005 --host=0.0.0.0
networks:
- devbox_freeleaps2-network
volumes:
- type: bind
source: /var/lib/docker/app/central_storage/log
target: /app/log/central_storage
authentication:
container_name: authentication
image: freeleaps.azurecr.io/authentication:latest-linux-arm64
# profiles: [ prod, alpha, dev ]
platform: linux/arm64
restart: always
environment:
- APP_NAME=authentication
- MONGODB_NAME=freeleaps2
- MONGODB_PORT=27017
- MONGODB_URI=mongodb://freeleaps2-mongodb:27017/
- SERVICE_API_ACCESS_HOST=localhost
- SERVICE_API_ACCESS_PORT=8004
- LOG_BASE_PATH=/app/log/authentication
- BACKEND_LOG_FILE_NAME=authentication.log
- APPLICATION_ACTIVITY_LOG=authentication-application.log
- NOTIFICATION_WEBAPI_URL_BASE=http://notification:8003/api/notification/
- DEVSVC_WEBAPI_URL_BASE=http://devsvc:8007/api/devsvc
- JWT_SECRET_KEY=ea84edf152976b2fcec12b78aa8e45bc26a5cf0ef61bf16f5c317ae33b3fd8b0
- JWT_ALGORITHM=HS256
ports:
- 8004:8004
command:
- /bin/sh
- -c
- |
uvicorn webapi.main:app --reload --port=8004 --host=0.0.0.0
networks:
- devbox_freeleaps2-network
volumes:
- type: bind
source: /var/lib/docker/app/authentication/log
target: /app/log/authentication
content:
container_name: content
image: freeleaps.azurecr.io/content:latest-linux-arm64
# profiles: [ prod, alpha, dev ]
platform: linux/arm64
restart: always
environment:
- APP_NAME=content
- SERVICE_API_ACCESS_HOST=localhost
- SERVICE_API_ACCESS_PORT=8013
- MONGODB_NAME=freeleaps2
- MONGODB_URI=mongodb://freeleaps2-mongodb:27017/
- FREELEAPS_WWW_AS_AZURE_CLIENT_SECRET=3gK8Q~PJbyWmiNqaGgho2ZqCY~OXzABSyN8wWasK
- CENTRAL_STORAGE_WEBAPI_URL_BASE=http://central_storage:8005/api/central_storage/
- LOG_BASE_PATH=/app/log/content
- BACKEND_LOG_FILE_NAME=content.log
- APPLICATION_ACTIVITY_LOG=content-application.log
ports:
- 8013:8013
command:
- /bin/sh
- -c
- |
uvicorn webapi.main:app --reload --port=8013 --host=0.0.0.0
networks:
- devbox_freeleaps2-network
volumes:
- type: bind
source: /var/lib/docker/app/content/log
target: /app/log/content
notification:
container_name: notification
image: freeleaps.azurecr.io/notification:latest-linux-arm64
# profiles: [ prod, alpha, dev ]
platform: linux/arm64
restart: always
environment:
- APP_NAME=notification
- SERVICE_API_ACCESS_HOST=localhost
- SERVICE_API_ACCESS_PORT=8003
- RABBITMQ_HOST=freeleaps2-rabbitmq
- RABBITMQ_PORT=5672
- SYSTEM_USER_ID=117f191e810c19729de860aa
- SMS_FROM=+16898887156
- EMAIL_FROM=freeleaps@freeleaps.com
- SECRET_KEY=ea84edf152976b2fcec12b78aa8e45bc26a5cf0ef61bf16f5c317ae33b3fd8b0
- SENDGRID_API_KEY=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
- TWILIO_ACCOUNT_SID=ACf8c9283a6acda060258eadb29be58bc8
- TWILIO_AUTH_TOKEN=ef160748cc22c8b7195b49df4b8eca7e
- LOG_BASE_PATH=/app/log/notification
- BACKEND_LOG_FILE_NAME=notification.log
- APPLICATION_ACTIVITY_LOG=notification-application.log
ports:
- 8003:8003
command:
- /bin/sh
- -c
- |
uvicorn webapi.main:app --reload --port=8003 --host=0.0.0.0
networks:
- devbox_freeleaps2-network
volumes:
- type: bind
source: /var/lib/docker/app/notification/log
target: /app/log/notification
volumes:
freeleaps2-mongodb-data:
freeleaps2-gitea-data:
freeleaps2-rabbitmq-data:
networks:
devbox_freeleaps2-network:
external: true

View File

@ -0,0 +1,221 @@
services:
gitea:
# For apple chip, add: platform: linux/amd64
container_name: freeleaps2-gitea
platform: linux/arm64
image: freeleaps.azurecr.io/gitea:latest-linux-arm64
restart: always
ports:
- "3000:3000"
environment:
- DISABLE_REGISTRATION=true
- REQUIRE_SIGNIN_VIEW=true
volumes:
- freeleaps2-gitea-data:/data
networks:
- devbox_freeleaps2-network
mongodb:
# For apple chip, add: platform: linux/amd64
# For apple chip, you may want to downgrade to public mongo:4.4 for log support
container_name: freeleaps2-mongodb
platform: linux/arm64
image: freeleaps.azurecr.io/mongo:latest-linux-arm64
restart: always
ports:
- "27017:27017"
volumes:
- freeleaps2-mongodb-data:/data/db
networks:
- devbox_freeleaps2-network
rabbitmq:
# For apple chip, add: platform: linux/amd64
platform: linux/arm64
container_name: freeleaps2-rabbitmq
image: freeleaps.azurecr.io/rabbitmq:latest-linux-arm64
restart: always
ports:
- "5672:5672"
- "15672:15672"
volumes:
- freeleaps2-rabbitmq-data:/var/lib/rabbitmq
networks:
- devbox_freeleaps2-network
devsvc:
container_name: devsvc
image: freeleaps.azurecr.io/devsvc:1.0.0
restart: always
environment:
- APP_NAME=devsvc
- SERVICE_API_ACCESS_HOST=localhost
- SERVICE_API_ACCESS_PORT=8007
- MONGODB_NAME=freeleaps2
- MONGODB_URI=mongodb://freeleaps2-mongodb:27017/
- GITEA_TOKEN=6786dc398b77d2a9c454b1943019425049deb667
- GITEA_URL=http://freeleaps2-gitea:3000
- CODE_DEPOT_HTTP_PORT=3443
- CODE_DEPOT_SSH_PORT=22
- CODE_DEPOT_DOMAIN_NAME=localhost
- RABBITMQ_HOST=freeleaps2-rabbitmq
- RABBITMQ_PORT=5672
- LOG_BASE_PATH=/app/log/devsvc
- BACKEND_LOG_FILE_NAME=devsvc.log
- APPLICATION_ACTIVITY_LOG=devsvc-application.log
ports:
- 8007:8007
command:
- /bin/sh
- -c
- |
uvicorn webapi.main:app --reload --port=8007 --host=0.0.0.0
volumes:
- type: bind
source: /var/lib/docker/app/devsvc/log
target: /app/log/devsvc
networks:
- devbox_freeleaps2-network
central_storage:
container_name: central_storage
image: freeleaps.azurecr.io/central_storage:latest-linux-arm64
# profiles: [ prod, alpha, dev ]
platform: linux/arm64
restart: always
environment:
- APP_NAME=central_storage
- MONGODB_NAME=freeleaps2
- MONGODB_PORT=27017
- MONGODB_URI=mongodb://freeleaps2-mongodb:27017/
- SERVICE_API_ACCESS_HOST=localhost
- SERVICE_API_ACCESS_PORT=8005
- AZURE_STORAGE_DOCUMENT_API_KEY=xbiFtFeQ6v5dozgVM99fZ9huUomL7QcLu6s0y8zYHtIXZ8XdneKDMcg4liQr/9oNlVoRFcZhWjLY+ASt9cjICQ==
- AZURE_STORAGE_DOCUMENT_API_ENDPOINT=https://freeleaps1document.blob.core.windows.net/
- LOG_BASE_PATH=/app/log/central_storage
- BACKEND_LOG_FILE_NAME=central_storage.log
- APPLICATION_ACTIVITY_LOG=central_storage-application.log
ports:
- 8005:8005
command:
- /bin/sh
- -c
- |
uvicorn webapi.main:app --reload --port=8005 --host=0.0.0.0
networks:
- devbox_freeleaps2-network
volumes:
- type: bind
source: /var/lib/docker/app/central_storage/log
target: /app/log/central_storage
authentication:
container_name: authentication
image: freeleaps.azurecr.io/authentication:latest-linux-arm64
# profiles: [ prod, alpha, dev ]
platform: linux/arm64
restart: always
environment:
- APP_NAME=authentication
- MONGODB_NAME=freeleaps2
- MONGODB_PORT=27017
- MONGODB_URI=mongodb://freeleaps2-mongodb:27017/
- SERVICE_API_ACCESS_HOST=localhost
- SERVICE_API_ACCESS_PORT=8004
- LOG_BASE_PATH=/app/log/authentication
- BACKEND_LOG_FILE_NAME=authentication.log
- APPLICATION_ACTIVITY_LOG=authentication-application.log
- NOTIFICATION_WEBAPI_URL_BASE=http://notification:8003/api/notification/
- DEVSVC_WEBAPI_URL_BASE=http://devsvc:8007/api/devsvc
- JWT_SECRET_KEY=ea84edf152976b2fcec12b78aa8e45bc26a5cf0ef61bf16f5c317ae33b3fd8b0
- JWT_ALGORITHM=HS256
ports:
- 8004:8004
command:
- /bin/sh
- -c
- |
uvicorn webapi.main:app --reload --port=8004 --host=0.0.0.0
networks:
- devbox_freeleaps2-network
volumes:
- type: bind
source: /var/lib/docker/app/authentication/log
target: /app/log/authentication
content:
container_name: content
image: freeleaps.azurecr.io/content:latest-linux-arm64
# profiles: [ prod, alpha, dev ]
platform: linux/arm64
restart: always
environment:
- APP_NAME=content
- SERVICE_API_ACCESS_HOST=localhost
- SERVICE_API_ACCESS_PORT=8013
- MONGODB_NAME=freeleaps2
- MONGODB_URI=mongodb://freeleaps2-mongodb:27017/
- FREELEAPS_WWW_AS_AZURE_CLIENT_SECRET=3gK8Q~PJbyWmiNqaGgho2ZqCY~OXzABSyN8wWasK
- CENTRAL_STORAGE_WEBAPI_URL_BASE=http://central_storage:8005/api/central_storage/
- LOG_BASE_PATH=/app/log/content
- BACKEND_LOG_FILE_NAME=content.log
- APPLICATION_ACTIVITY_LOG=content-application.log
ports:
- 8013:8013
command:
- /bin/sh
- -c
- |
uvicorn webapi.main:app --reload --port=8013 --host=0.0.0.0
networks:
- devbox_freeleaps2-network
volumes:
- type: bind
source: /var/lib/docker/app/content/log
target: /app/log/content
notification:
container_name: notification
image: freeleaps.azurecr.io/notification:latest-linux-arm64
# profiles: [ prod, alpha, dev ]
platform: linux/arm64
restart: always
environment:
- APP_NAME=notification
- SERVICE_API_ACCESS_HOST=localhost
- SERVICE_API_ACCESS_PORT=8003
- RABBITMQ_HOST=freeleaps2-rabbitmq
- RABBITMQ_PORT=5672
- SYSTEM_USER_ID=117f191e810c19729de860aa
- SMS_FROM=+16898887156
- EMAIL_FROM=freeleaps@freeleaps.com
- SECRET_KEY=ea84edf152976b2fcec12b78aa8e45bc26a5cf0ef61bf16f5c317ae33b3fd8b0
- SENDGRID_API_KEY=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
- TWILIO_ACCOUNT_SID=ACf8c9283a6acda060258eadb29be58bc8
- TWILIO_AUTH_TOKEN=ef160748cc22c8b7195b49df4b8eca7e
- LOG_BASE_PATH=/app/log/notification
- BACKEND_LOG_FILE_NAME=notification.log
- APPLICATION_ACTIVITY_LOG=notification-application.log
ports:
- 8003:8003
command:
- /bin/sh
- -c
- |
uvicorn webapi.main:app --reload --port=8003 --host=0.0.0.0
networks:
- devbox_freeleaps2-network
volumes:
- type: bind
source: /var/lib/docker/app/notification/log
target: /app/log/notification
volumes:
freeleaps2-mongodb-data:
freeleaps2-gitea-data:
freeleaps2-rabbitmq-data:
networks:
devbox_freeleaps2-network:
external: true

View File

@ -0,0 +1,85 @@
services:
gitea:
# For apple chip, add: platform: linux/amd64
container_name: freeleaps2-gitea
image: freeleaps.azurecr.io/gitea:1.20.4
restart: always
ports:
- "3000:3000"
environment:
- DISABLE_REGISTRATION=true
- REQUIRE_SIGNIN_VIEW=true
volumes:
- freeleaps2-gitea-data:/data
networks:
- freeleaps2-network
mongodb:
# For apple chip, add: platform: linux/amd64
# For apple chip, you may want to downgrade to public mongo:4.4 for log support
container_name: freeleaps2-mongodb
image: freeleaps.azurecr.io/mongo:latest
restart: always
ports:
- "27017:27017"
volumes:
- freeleaps2-mongodb-data:/data/db
networks:
- freeleaps2-network
rabbitmq:
# For apple chip, add: platform: linux/amd64
container_name: freeleaps2-rabbitmq
image: freeleaps.azurecr.io/rabbitmq:3.13
restart: always
ports:
- "5672:5672"
- "15672:15672"
volumes:
- freeleaps2-rabbitmq-data:/var/lib/rabbitmq
networks:
- freeleaps2-network
devsvc:
container_name: devsvc
image: freeleaps.azurecr.io/devsvc:1.0.0
restart: always
environment:
- APP_NAME=devsvc
- SERVICE_API_ACCESS_HOST=localhost
- SERVICE_API_ACCESS_PORT=8007
- MONGODB_NAME=freeleaps2
- MONGODB_URI=mongodb://freeleaps2-mongodb:27017/
- GITEA_TOKEN=6786dc398b77d2a9c454b1943019425049deb667
- GITEA_URL=http://freeleaps2-gitea:3000
- CODE_DEPOT_HTTP_PORT=3443
- CODE_DEPOT_SSH_PORT=22
- CODE_DEPOT_DOMAIN_NAME=localhost
- RABBITMQ_HOST=freeleaps2-rabbitmq
- RABBITMQ_PORT=5672
- LOG_BASE_PATH=/app/log/devsvc
- BACKEND_LOG_FILE_NAME=devsvc.log
- APPLICATION_ACTIVITY_LOG=devsvc-application.log
ports:
- 8007:8007
command:
- /bin/sh
- -c
- |
uvicorn webapi.main:app --reload --port=8007 --host=0.0.0.0
volumes:
- type: bind
source: /var/lib/docker/app/devsvc/log
target: /app/log/devsvc
networks:
- freeleaps2-network
volumes:
freeleaps2-mongodb-data:
freeleaps2-gitea-data:
freeleaps2-rabbitmq-data:
networks:
freeleaps2-network:
driver: bridge

View File

@ -0,0 +1,11 @@
#!/bin/bash
# start SSH Daemon
/usr/sbin/sshd -D &
sleep 20
rm -rf /var/run/docker.pid || true
# start Docker Daemon
/usr/bin/dockerd --pidfile="" --storage-driver vfs &
tail -f /dev/null

View File

@ -0,0 +1,18 @@
#!/bin/bash
# start SSH Daemon
if ! pgrep -x "sshd" > /dev/null
then
echo "Starting sshd..."
/usr/sbin/sshd -D &
fi
sleep 60
# start Docker Daemon
if ! pgrep -x "dockerd" > /dev/null
then
rm -rf /var/run/docker.pid || true
echo "Starting Docker Daemon..."
/usr/bin/dockerd --pidfile="" --storage-driver vfs &
disown -a
fi

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,78 @@
#!/bin/bash
sudo tar -xzvf gitea_data_backup.tar.gz
# Get the architecture using the `arch` command
ARCH=$(arch 2>/dev/null)
# Check the architecture and set PLATFORM accordingly
if [ "$ARCH" = "aarch64" ]; then
DOCKER_COMPOSE_FILE="docker-compose.dev.arm64.yaml"
elif [ "$ARCH" = "x86_64" ]; then
DOCKER_COMPOSE_FILE="docker-compose.dev.yaml"
else
DOCKER_COMPOSE_FILE="docker-compose.dev.yaml"
fi
pushd ~/freeleaps/
if [ ! -d ~/freeleaps/freeleaps2-backend ]; then
echo "Git cloning freeleaps2-backend"
git clone --depth 5 https://freeleaps@dev.azure.com/freeleaps/freeleaps2-backend/_git/freeleaps2-backend
else
pushd ~/freeleaps/freeleaps2-backend
echo "Git pulling freeleaps2-backend"
git pull
popd
fi
if [ ! -d ~/freeleaps/freeleaps2-frontend ]; then
echo "Git cloning freeleaps2-frontend"
git clone --depth 5 https://freeleaps@dev.azure.com/freeleaps/freeleaps2-frontend/_git/freeleaps2-frontend
else
pushd ~/freeleaps/freeleaps2-frontend
echo "Git pulling freeleaps2-frontend"
git pull
popd
fi
popd
source ~/devbox/.dev.env
if [ ! -f ~/.docker/config.json ]; then
echo "Docker config not found, creating..."
if [ ! -f ~/.acr_token ]; then
echo "ACR token file not found, run acr_login.sh first"
./acr_login.sh
else
FREELEAPS_ACR_TOKEN=$(cat ~/.acr_token)
docker login freeleaps.azurecr.io --username 00000000-0000-0000-0000-000000000000 --password-stdin <<< $FREELEAPS_ACR_TOKEN
fi
fi
docker compose -f ./${DOCKER_COMPOSE_FILE} up -d mongodb
pip install -r ~/freeleaps/freeleaps2-backend/requirements.txt
pushd ~/freeleaps/freeleaps2-backend/tools
./initialize_collections_devbox.sh
popd
docker volume create devbox_freeleaps2-gitea-data
GITEA_DATA=$(docker volume inspect devbox_freeleaps2-gitea-data | jq -r '.[0].Mountpoint')
if [[ -d "${GITEA_DATA}/gitea" ]]; then
echo "Gitea data exist, skipping..."
else
echo "Gitea data not exist, copying..."
sudo rm -rf ${GITEA_DATA}/git
sudo rm -rf ${GITEA_DATA}/gitea
sudo rm -rf ${GITEA_DATA}/ssh
sudo mv data/git ${GITEA_DATA}/
sudo mv data/gitea ${GITEA_DATA}/
sudo mv data/ssh ${GITEA_DATA}/
sudo chown -R freedev:freedev ${GITEA_DATA}
echo "Gitea data copying is done"
fi
docker compose -f ./${DOCKER_COMPOSE_FILE} up -d

View File

@ -0,0 +1,45 @@
#!/bin/bash
export CONTAINER_NAME="devbox_local"
if [ ! -d "./freeleaps" ]; then
echo "Error: ./freeleaps directory does not exist."
return 1
fi
if [ ! -f "./.acr_token" ]; then
echo "Error: .acr_token file does not exist or is empty. Please run acr_login.sh first."
return 1
fi
# Try to get the architecture using the `arch` command
ARCH=$(arch 2>/dev/null)
# Check if the architecture is 'arm64'
if [ "$ARCH" = "arm64" ]; then
TAG="latest-linux-arm64"
ACR_TOKEN="acr_token"
else
TAG="latest-linux-amd64"
ACR_TOKEN=".acr_token"
fi
if ! docker pull freeleaps.azurecr.io/devbox_v3:${TAG}; then
echo "Error: Failed to pull the latest devbox_v3 image."
return 1
fi
if docker ps --format '{{.Names}}' | grep -q ^${CONTAINER_NAME}$; then
echo "Container '${CONTAINER_NAME}' is already running."
return 0
fi
if ! docker run --privileged -d -p 22222:22 \
-v ./freeleaps:/mnt/freeleaps \
-v ./${ACR_TOKEN}:/home/freedev/devbox/.acr_token \
-v ./var/lib/docker/app/devsvc/log:/var/lib/docker/app/devsvc/log \
--name ${CONTAINER_NAME} freeleaps.azurecr.io/devbox_v3:${TAG}; then
echo "Error: Failed to start the ${CONTAINER_NAME} container."
return 1
fi
echo "${CONTAINER_NAME} container started successfully."

View File

@ -0,0 +1,29 @@
fastapi==0.100.1
fastapi-mail==1.4.1
loguru~=0.6.0
uvicorn==0.23.2
pydantic==2.1.1
pydantic-settings
python-multipart
python-jose[cryptography]
passlib[bcrypt]
beanie==1.21.0
frozendict==2.3.8
fastapi-jwt==0.2.0
requests==2.31.0
pymongo==4.3.3
jieba==0.42.1
APScheduler==3.10.4
python-dateutil==2.8.2
stripe==8.1.0
strawberry-graphql==0.236.0
websockets==12.0
pika==1.3.2
aio-pika
twilio
openai
pillow
azure-storage-blob[aio]
azure-identity
azure-core[aio]
sendgrid

View File

@ -0,0 +1,28 @@
#!/bin/bash
export CONTAINER_NAME="devbox_local"
if ! docker ps -a --format '{{.Names}}' | grep -q ^${CONTAINER_NAME}$; then
echo "Container '${CONTAINER_NAME}' does not exist."
exit 1
fi
container_state=$(docker inspect --format '{{.State.Status}}' ${CONTAINER_NAME})
if [ "$container_state" = "running" ]; then
echo "Container '${CONTAINER_NAME}' is already running."
elif [ "$container_state" = "exited" ]; then
echo "Container '${CONTAINER_NAME}' is stopped. Starting it..."
if ! docker start ${CONTAINER_NAME}; then
echo "Error: Failed to start the ${CONTAINER_NAME} container."
exit 1
fi
docker exec ${CONTAINER_NAME} /usr/local/bin/entrypoint_restore.sh
echo "Container '${CONTAINER_NAME}' started successfully."
else
echo "Container '${CONTAINER_NAME}' is in an unknown state: $container_state"
exit 1
fi

View File

@ -0,0 +1,6 @@
#!/bin/bash
pushd ~/devbox
source .dev.env
docker compose -f ./docker-compose.dev.yaml up -d
popd

View File

@ -0,0 +1,11 @@
#!/bin/bash
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
source $BASE_DIR/.dev.env
pushd ~/freeleaps/freeleaps2-backend
source $BASE_DIR/.dev.env
docker compose -f ~/devbox/docker-compose.dev.yaml up -d
pkill -f "uvicorn webapi.main:app" || true
./start_webapi.sh
popd

View File

@ -0,0 +1,13 @@
#!/bin/bash
pushd ~/freeleaps/freeleaps2-frontend/frontend
export VITE_API_URL='http://127.0.0.1:8002'
export VITE_WEBSOCKET_URL='http://127.0.0.1:8002'
source ~/devbox/.dev.env
npm config set "@fortawesome:registry" https://npm.fontawesome.com/
npm config set "//npm.fontawesome.com/:_authToken" 58624E90-2685-43C6-BF0F-0BFECCE11CD2
npm config set registry
npm update
npm install
npm run build
npm run dev
popd

View File

@ -0,0 +1,13 @@
#!/bin/bash
pushd ~/freeleaps/freeleaps2-frontend/frontend
export VITE_API_URL='http://127.0.0.1:8002'
export VITE_WEBSOCKET_URL='http://127.0.0.1:8002'
source ~/devbox/.dev.env
npm config set "@fortawesome:registry" https://npm.fontawesome.com/
npm config set "//npm.fontawesome.com/:_authToken" 58624E90-2685-43C6-BF0F-0BFECCE11CD2
npm config set registry https://registry.npmmirror.com
npm update
npm install
npm run build
npm run dev
popd

View File

@ -0,0 +1,11 @@
#!/bin/bash
export CONTAINER_NAME="devbox_local"
if docker ps -a --format '{{.Names}}' | grep -q ^${CONTAINER_NAME}$; then
echo "Docker container '${CONTAINER_NAME}' exists. Stopping it..."
docker stop ${CONTAINER_NAME}
echo "Docker container '${CONTAINER_NAME}' has been stopped."
else
echo "Docker container '${CONTAINER_NAME}' does not exist."
fi

View File

@ -0,0 +1,6 @@
#!/bin/bash
pushd ~/devbox
source .dev.env
docker compose -f ./docker-compose.dev.yaml down
popd

View File

@ -0,0 +1,24 @@
export MONGODB_NAME=freeleaps2
export MONGODB_URI=mongodb://localhost:27017/
export EMAIL_FROM=support@freeleaps.com
export GITEA_TOKEN=6786dc398b77d2a9c454b1943019425049deb667
export GITEA_URL=http://freeleaps2-gitea:3000
export GITEA_DOMAIN_NAME=localhost
export GITEA_HTTP_PORT=3000
export SITE_ACCESS_PORT=80
export FREELEAPS_ENV=dev
export STRIPE_API_KEY=sk_test_51Ogsw5B0IyqaSJBrwczlr820jnmvA1qQQGoLZ2XxOsIzikpmXo4pRLjw4XVMTEBR8DdVTYySiAv1XX53Zv5xqynF00GfMqttFd
export STRIPE_WEBHOOK_SECRET=
export SITE_URL_ROOT=http://localhost/
export AZURE_TRANSLATION_API_KEY=eaf4c14eb06b4cd790e90111dc6e9f57
export AZURE_TRANSLATION_API_LOCATION=global
export AZURE_OPENAI_API_KEY=3550d2ce7c494ebd8b54c5528ac8a613
export AZURE_STORAGE_DOCUMENT_API_KEY=xbiFtFeQ6v5dozgVM99fZ9huUomL7QcLu6s0y8zYHtIXZ8XdneKDMcg4liQr/9oNlVoRFcZhWjLY+ASt9cjICQ==
export JWT_SECRET_KEY=ea84edf152976b2fcec12b78aa8e45bc26a5cf0ef61bf16f5c317ae33b3fd8b0
export RABBITMQ_HOST=localhost
export RABBITMQ_PORT=5672
export TWILIO_ACCOUNT_SID=ACf8c9283a6acda060258eadb29be58bc8
export TWILIO_AUTH_TOKEN=ef160748cc22c8b7195b49df4b8eca7e
export FONTAWESOME_AUTH_TOKEN=58624E90-2685-43C6-BF0F-0BFECCE11CD2
export FREELEAPS_WWW_AS_AZURE_CLIENT_SECRET=3gK8Q~PJbyWmiNqaGgho2ZqCY~OXzABSyN8wWasK
export SENDGRID_API_KEY='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'

View File

@ -0,0 +1,76 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# upgrade and install basic tools
RUN apt-get update && \
apt-get install -y \
sudo \
openssh-server \
jq \
vim \
git \
python3.10 \
python3-pip \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
mkdir /var/run/sshd
# install Node.js and npm
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - && \
apt-get install -y nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# install Docker
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
apt-get update && \
apt-get install -y docker-ce docker-ce-cli containerd.io && \
rm -rf /var/lib/apt/lists/*
# install Docker Compose
RUN curl -L "https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose
# config SSH
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config && \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && \
sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config && \
sed -i 's/#ClientAliveInterval 0/ClientAliveInterval 60/' /etc/ssh/sshd_config && \
sed -i 's/#ClientAliveCountMax 3/ClientAliveCountMax 5/' /etc/ssh/sshd_config
# expose SSH port
EXPOSE 22
# copy start.sh
COPY start.sh /usr/local/bin/start.sh
RUN chmod +x /usr/local/bin/start.sh
# set python3 as default python
RUN ln -s /usr/bin/python3 /usr/bin/python
# copy devbox files
RUN mkdir -p /opt/devbox/ /mnt/docker_data/
COPY requirements.txt /opt/devbox/requirements.txt
COPY init_open_box.sh init_devbox.sh start_backend_for_dev.sh start_frontend_for_dev.sh gitea_data_backup.tar.gz .dev.env /opt/devbox/
RUN chmod +x /opt/devbox/*.sh
RUN pip3 install -r /opt/devbox/requirements.txt
# configure Docker data root
RUN echo '{"data-root": "/mnt/docker_data/docker"}' > /etc/docker/daemon.json
RUN useradd -u 1001 -m -s /bin/bash freedev && \
echo "freedev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
usermod -aG docker freedev;
# start
CMD ["/usr/local/bin/start.sh"]

Binary file not shown.

View File

@ -0,0 +1,33 @@
#!/bin/bash
sudo tar -xzvf gitea_data_backup.tar.gz
pushd ~/freeleaps/
git clone https://freeleaps@dev.azure.com/freeleaps/freeleaps2-backend/_git/freeleaps2-backend
git clone https://freeleaps@dev.azure.com/freeleaps/freeleaps2-frontend/_git/freeleaps2-frontend
popd
source ~/devbox/.dev.env
pushd ~/freeleaps/freeleaps2-backend
docker compose build -f ./docker-compose.dev.yaml
docker compose up -d mongodb
pushd ~/freeleaps/freeleaps2-backend/tools
./initialize_collections.sh
popd
popd
docker volume create freeleaps2-backend_freeleaps2-gitea-data
GITEA_DATA=$(docker volume inspect freeleaps2-backend_freeleaps2-gitea-data | jq -r '.[0].Mountpoint')
if [[ -d "${GITEA_DATA}/gitea" ]]; then
echo "Gitea data exist, skipping.."
else
echo "Gitea data not exist, copying.."
sudo rm -rf ${GITEA_DATA}/git
sudo rm -rf ${GITEA_DATA}/gitea
sudo rm -rf ${GITEA_DATA}/ssh
sudo mv data/git ${GITEA_DATA}/
sudo mv data/gitea ${GITEA_DATA}/
sudo mv data/ssh ${GITEA_DATA}/
sudo chown -R root:root ${GITEA_DATA}
fi

View File

@ -0,0 +1,10 @@
#!/bin/bash
apt update -y
apt install sudo
apt install vim
apt install nodejs
apt install npm
read -p "Enter your FLID (the part before '@' in your freeleaps.com email ): " FLID
read -p "Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
source ./init_flid_account.sh $FLID
sudo -s -u $FLID source ./init_devbox.sh

View File

@ -0,0 +1,25 @@
fastapi==0.100.1
fastapi-mail==1.4.1
loguru~=0.6.0
uvicorn==0.23.2
pydantic==2.1.1
pydantic-settings
python-multipart
python-jose[cryptography]
passlib[bcrypt]
beanie==1.21.0
frozendict==2.3.8
fastapi-jwt==0.2.0
requests==2.31.0
pymongo==4.3.3
jieba==0.42.1
APScheduler==3.10.4
python-dateutil==2.8.2
stripe==8.1.0
Office365-REST-Python-Client==2.5.10
websockets==12.0
pika==1.3.2
aio-pika
twilio
openai
pillow

View File

@ -0,0 +1,6 @@
#!/bin/bash
# start SSH Daemon
/usr/sbin/sshd -D &
# start Docker Daemon
dockerd

View File

@ -0,0 +1,8 @@
#!/bin/bash
pushd ~/freeleaps/freeleaps2-backend
source ~/devbox/.dev.env
docker compose -f ./docker-compose.dev.yaml up -d
pkill -f "uvicorn webapi.main:app" || true
./start_webapi.sh
popd

View File

@ -0,0 +1,12 @@
#!/bin/bash -x
pushd ~/freeleaps/freeleaps2-frontend/frontend
export VITE_API_URL='http://127.0.0.1:8002'
export VITE_WEBSOCKET_URL='http://127.0.0.1:8002'
source ~/devbox/.dev.env
npm config set "@fortawesome:registry" https://npm.fontawesome.com/
npm config set "//npm.fontawesome.com/:_authToken" 58624E90-2685-43C6-BF0F-0BFECCE11CD2
npm update
npm install
npm run build
npm run dev
popd

View File

@ -0,0 +1,7 @@
#!/bin/bash
pushd ~/freeleaps/freeleaps2-backend
source ~/devbox/.dev.env
docker compose -f ./docker-compose.dev.yaml down
pkill -f "uvicorn webapi.main:app" || true
popd