Merge pull request #2311 from bluewave-labs/fix/monolithic-docker
fix: monolithic docker
This commit is contained in:
9 files changed
+134
-4
No files matched your search
@@ -11,9 +11,6 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Log in to GitHub Container Registry
|
- name: Log in to GitHub Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
name: Distribution deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["master"]
|
||||||
|
workflow_dispatch:
|
||||||
|
jobs:
|
||||||
|
docker-build-and-push-server:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Log in to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build Server Docker image
|
||||||
|
run: |
|
||||||
|
docker build \
|
||||||
|
-t ghcr.io/bluewave-labs/checkmate:backend-dist-mono \
|
||||||
|
-f ./docker/dist-mono/server.Dockerfile \
|
||||||
|
--label org.opencontainers.image.source=https://github.com/bluewave-labs/checkmate \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Push Server Docker image
|
||||||
|
run: docker push ghcr.io/bluewave-labs/checkmate:backend-dist-mono
|
||||||
+2
-1
@@ -8,5 +8,6 @@ dist/redis/data/*
|
|||||||
prod/mongo/data/*
|
prod/mongo/data/*
|
||||||
prod/redis/data/*
|
prod/redis/data/*
|
||||||
dist/docker-compose-test.yaml
|
dist/docker-compose-test.yaml
|
||||||
|
/dist-mono/mongo/data/*
|
||||||
|
/dist-mono/redis/data/*
|
||||||
*.env
|
*.env
|
||||||
prod/certbot/*
|
|
||||||
Executable
+29
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Change directory to root Server directory for correct Docker Context
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Define service names and their corresponding Dockerfiles in parallel arrays
|
||||||
|
services=("mono_mongo" "mono_redis" "mono_server")
|
||||||
|
dockerfiles=(
|
||||||
|
"./docker/dist-mono/mongoDB.Dockerfile"
|
||||||
|
"./docker/dist-mono/redis.Dockerfile"
|
||||||
|
"./docker/dist-mono/server.Dockerfile"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Loop through each service and build the corresponding image
|
||||||
|
for i in "${!services[@]}"; do
|
||||||
|
service="${services[$i]}"
|
||||||
|
dockerfile="${dockerfiles[$i]}"
|
||||||
|
|
||||||
|
docker build -f "$dockerfile" -t "$service" .
|
||||||
|
|
||||||
|
# Check if the build succeeded
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error building $service image. Exiting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "All images built successfully"
|
||||||
Executable
+36
@@ -0,0 +1,36 @@
|
|||||||
|
services:
|
||||||
|
server:
|
||||||
|
image: ghcr.io/bluewave-labs/checkmate:backend-dist-mono
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "52345:52345"
|
||||||
|
environment:
|
||||||
|
- UPTIME_APP_API_BASE_URL=http://localhost:52345/api/v1
|
||||||
|
- UPTIME_APP_CLIENT_HOST=http://localhost
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
- mongodb
|
||||||
|
redis:
|
||||||
|
image: ghcr.io/bluewave-labs/checkmate:redis-dist
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./redis/data:/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "redis-cli", "ping"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 5
|
||||||
|
start_period: 5s
|
||||||
|
mongodb:
|
||||||
|
image: ghcr.io/bluewave-labs/checkmate:mongo-dist
|
||||||
|
restart: always
|
||||||
|
command: ["mongod", "--quiet", "--replSet", "rs0", "--bind_ip_all"]
|
||||||
|
volumes:
|
||||||
|
- ./mongo/data:/data/db
|
||||||
|
healthcheck:
|
||||||
|
test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'mongodb:27017'}]}) }" | mongosh --port 27017 --quiet
|
||||||
|
interval: 5s
|
||||||
|
timeout: 30s
|
||||||
|
start_period: 0s
|
||||||
|
start_interval: 1s
|
||||||
|
retries: 30
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
FROM mongo
|
||||||
|
EXPOSE 27017
|
||||||
|
CMD ["mongod"]
|
||||||
Executable
+2
@@ -0,0 +1,2 @@
|
|||||||
|
FROM redis
|
||||||
|
EXPOSE 6379
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
FROM node:20-alpine AS frontend-build
|
||||||
|
|
||||||
|
WORKDIR /app/client
|
||||||
|
|
||||||
|
COPY client/package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY client ./
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM node:20-alpine AS app
|
||||||
|
|
||||||
|
WORKDIR /app/server
|
||||||
|
|
||||||
|
COPY server ./
|
||||||
|
|
||||||
|
COPY --from=frontend-build /app/client/dist ./public
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
RUN chmod +x ./scripts/inject-vars.sh
|
||||||
|
|
||||||
|
EXPOSE 52345
|
||||||
|
|
||||||
|
CMD ./scripts/inject-vars.sh && node ./index.js
|
||||||
@@ -99,6 +99,8 @@ const openApiSpec = JSON.parse(
|
|||||||
fs.readFileSync(path.join(__dirname, "openapi.json"), "utf8")
|
fs.readFileSync(path.join(__dirname, "openapi.json"), "utf8")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const frontendPath = path.join(__dirname, "public");
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
|
|
||||||
const shutdown = async () => {
|
const shutdown = async () => {
|
||||||
@@ -308,6 +310,7 @@ const startApp = async () => {
|
|||||||
const notificationRoutes = new NotificationRoutes(notificationController);
|
const notificationRoutes = new NotificationRoutes(notificationController);
|
||||||
const diagnosticRoutes = new DiagnosticRoutes(diagnosticController);
|
const diagnosticRoutes = new DiagnosticRoutes(diagnosticController);
|
||||||
// Middleware
|
// Middleware
|
||||||
|
app.use(express.static(frontendPath));
|
||||||
app.use(responseHandler);
|
app.use(responseHandler);
|
||||||
app.use(
|
app.use(
|
||||||
cors({
|
cors({
|
||||||
@@ -353,6 +356,10 @@ const startApp = async () => {
|
|||||||
status: "OK",
|
status: "OK",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// FE routes
|
||||||
|
app.get("*", (req, res) => {
|
||||||
|
res.sendFile(path.join(frontendPath, "index.html"));
|
||||||
|
});
|
||||||
app.use(handleErrors);
|
app.use(handleErrors);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user