fix(dockerfile): Update Docker base images to use code.foss.global instead of registry.gitlab.com

This commit is contained in:
Philipp Kunz 2024-11-18 15:21:48 +01:00
parent 4f58a912da
commit d812e21b50
9 changed files with 8972 additions and 3012 deletions

View File

@ -1,6 +1,6 @@
# gitzone dockerfile_service
## STAGE 1 // BUILD
FROM registry.gitlab.com/hosttoday/ht-docker-node:npmci as node1
FROM code.foss.global/host.today/ht-docker-node:npmci as node1
COPY ./ /app
WORKDIR /app
ARG NPMCI_TOKEN_NPM2
@ -12,7 +12,7 @@ RUN pnpm run build
# gitzone dockerfile_service
## STAGE 2 // install production
FROM registry.gitlab.com/hosttoday/ht-docker-node:npmci as node2
FROM code.foss.global/host.today/ht-docker-node:npmci as node2
WORKDIR /app
COPY --from=node1 /app /app
RUN rm -rf .pnpm-store
@ -24,7 +24,7 @@ RUN rm -rf node_modules/ && pnpm install --prod
## STAGE 3 // rebuild dependencies for alpine
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpinenpmci as node3
FROM code.foss.global/host.today/ht-docker-node:alpine_npmci as node3
WORKDIR /app
COPY --from=node2 /app /app
ARG NPMCI_TOKEN_NPM2
@ -34,12 +34,12 @@ RUN pnpm config set store-dir .pnpm-store
RUN pnpm rebuild -r
## STAGE 4 // the final production image with all dependencies in place
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpine as node4
FROM code.foss.global/host.today/ht-docker-node:alpine as node4
WORKDIR /app
COPY --from=node3 /app /app
### Healthchecks
RUN pnpm install -g @serve.zone/healthy
RUN pnpm install -g @servezone/healthy
HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 CMD [ "healthy" ]
EXPOSE 80

13
changelog.md Normal file
View File

@ -0,0 +1,13 @@
# Changelog
## 2024-11-18 - 1.0.133 - fix(dockerfile)
Update Docker base images to use code.foss.global instead of registry.gitlab.com
- Updated Docker base images to use `code.foss.global` instead of `registry.gitlab.com`.
- Changed the global installation path for `@serve.zone/healthy` to `@servezone/healthy` in Dockerfile.
- Adjusted logging system from `lole-log` to `smartlog` for enhanced log context output.
## 2024-05-09 - 1.0.130 to 1.0.132 - Maintenance Release
Regular updates and maintenance tasks.
- Fixed core functionality issues in versions 1.0.130 and 1.0.131.

View File

@ -16,7 +16,7 @@
"githost": "gitlab.com",
"gitscope": "losslessone/services/servezone",
"gitrepo": "coreflow",
"description": "A comprehensive solution for managing Docker and scaling applications across servers, handling tasks from service provisioning to network traffic management.",
"description": "A comprehensive tool for managing Docker-based applications and services, enabling efficient scaling, network management, and integration with cloud services.",
"npmPackagename": "@serve.zone/coreflow",
"license": "UNLICENSED",
"keywords": [
@ -31,13 +31,19 @@
"Web services",
"Container management",
"Cluster configuration",
"DevOps tools",
"Cloud services integration",
"Security management",
"High availability services",
"Multi-cloud orchestration",
"DevOps",
"Cloud integration",
"Security",
"High availability",
"Multi-cloud",
"Service discovery",
"Distributed systems"
"Distributed systems",
"Docker Swarm",
"Traffic management",
"Service provisioning",
"Monitoring",
"Observability",
"TypeScript"
]
}
}

View File

@ -1,7 +1,7 @@
{
"name": "@serve.zone/coreflow",
"version": "1.0.132",
"description": "A comprehensive solution for managing Docker and scaling applications across servers, handling tasks from service provisioning to network traffic management.",
"description": "A comprehensive tool for managing Docker-based applications and services, enabling efficient scaling, network management, and integration with cloud services.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
@ -31,13 +31,19 @@
"Web services",
"Container management",
"Cluster configuration",
"DevOps tools",
"Cloud services integration",
"Security management",
"High availability services",
"Multi-cloud orchestration",
"DevOps",
"Cloud integration",
"Security",
"High availability",
"Multi-cloud",
"Service discovery",
"Distributed systems"
"Distributed systems",
"Docker Swarm",
"Traffic management",
"Service provisioning",
"Monitoring",
"Observability",
"TypeScript"
],
"author": "Lossless GmbH",
"license": "MIT",
@ -46,35 +52,35 @@
},
"homepage": "https://gitlab.com/pushrocks/coreflow#readme",
"devDependencies": {
"@git.zone/tsbuild": "^2.1.66",
"@git.zone/tsrun": "^1.2.46",
"@git.zone/tsbuild": "^2.2.0",
"@git.zone/tsrun": "^1.3.3",
"@git.zone/tstest": "^1.0.90",
"@git.zone/tswatch": "^2.0.7",
"@push.rocks/tapbundle": "^5.0.23"
"@git.zone/tswatch": "^2.0.25",
"@push.rocks/tapbundle": "^5.5.0"
},
"dependencies": {
"@api.global/typedrequest": "^3.0.23",
"@api.global/typedrequest": "^3.1.10",
"@api.global/typedsocket": "^3.0.1",
"@apiclient.xyz/docker": "^1.0.112",
"@apiclient.xyz/docker": "^1.2.7",
"@push.rocks/early": "^4.0.3",
"@push.rocks/lik": "^6.0.15",
"@push.rocks/lik": "^6.1.0",
"@push.rocks/projectinfo": "^5.0.1",
"@push.rocks/qenv": "^6.0.5",
"@push.rocks/smartcli": "^4.0.10",
"@push.rocks/smartcli": "^4.0.11",
"@push.rocks/smartdelay": "^3.0.1",
"@push.rocks/smartlog": "^3.0.2",
"@push.rocks/smartlog": "^3.0.7",
"@push.rocks/smartnetwork": "3.0.2",
"@push.rocks/smartpath": "^5.0.18",
"@push.rocks/smartpromise": "^4.0.2",
"@push.rocks/smartrequest": "^2.0.22",
"@push.rocks/smartpromise": "^4.0.4",
"@push.rocks/smartrequest": "^2.0.23",
"@push.rocks/smartrx": "^3.0.2",
"@push.rocks/smartstate": "^2.0.6",
"@push.rocks/smartstate": "^2.0.19",
"@push.rocks/smartstring": "^4.0.15",
"@push.rocks/taskbuffer": "^3.0.10",
"@serve.zone/api": "^2.0.28",
"@serve.zone/interfaces": "^1.0.51",
"@tsclass/tsclass": "^4.0.54",
"@types/node": "20.12.11"
"@serve.zone/api": "^4.3.11",
"@serve.zone/interfaces": "^4.3.11",
"@tsclass/tsclass": "^4.1.2",
"@types/node": "22.9.0"
},
"private": true,
"files": [

11521
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

232
readme.md
View File

@ -2,20 +2,26 @@
A comprehensive solution for managing Docker and scaling applications across servers, handling tasks from service provisioning to network traffic management.
## Install
To install @serve.zone/coreflow, you can use npm with the following command:
```sh
npm install @serve.zone/coreflow --save
```
Given that this is a private package, make sure you have access to the required npm registry and that you are authenticated properly.
## Usage
Coreflow is designed as an advanced tool for managing Docker-based applications and services, enabling efficient scaling across servers, and handling multiple aspects of service provisioning and network traffic management. Below are examples and explanations to illustrate its capabilities and how you can leverage Coreflow in your infrastructure. Note that these examples are based on TypeScript and use ESM syntax.
### Prerequisites
Before you start, ensure you have Docker and Docker Swarm configured in your environment as Coreflow operates on top of these technologies. Additionally, verify that your environment variables are properly set up for accessing Coreflow's functionalities.
### Setting Up Coreflow
To get started, you need to import and initialize coreflow within your application. Here's an example of how to do this in a TypeScript module:
To get started, you need to import and initialize Coreflow within your application. Here's an example of how to do this in a TypeScript module:
```typescript
import { Coreflow } from '@serve.zone/coreflow';
@ -35,7 +41,14 @@ coreflowInstance.handleDockerEvents().then(() => {
await coreflowInstance.stop();
```
In the above example:
- The Coreflow instance is initialized.
- Coreflow is started, which internally initializes various managers and connectors.
- The method `handleDockerEvents` is used to handle Docker events.
- Finally, Coreflow is stopped gracefully.
### Configuring Service Connections
Coreflow manages applications and services, often requiring direct interactions with other services like a database, message broker, or external API. Coreflow simplifies these connections through its configuration and service discovery layers.
```typescript
@ -51,6 +64,7 @@ serviceConnection.connect().then(() => {
```
### Scaling Your Application
Coreflow excels in scaling applications across multiple servers. This involves not just replicating services, but also ensuring they are properly networked, balanced, and monitored.
```typescript
@ -66,7 +80,12 @@ coreflowInstance.applyScalingPolicy(scalingPolicy).then(() => {
});
```
In the above example:
- A scaling policy is defined with target, maximum, and minimum replica counts for the `apiService`.
- The `applyScalingPolicy` method of the Coreflow instance is used to apply this scaling policy.
### Managing Network Traffic
One of Coreflow's key features is its ability to manage network traffic, ensuring that it is efficiently distributed among various services based on load, priority, and other custom rules.
```typescript
@ -84,7 +103,12 @@ coreflowInstance.applyTrafficRule(rule).then(() => {
});
```
In the above example:
- A traffic rule is defined for the `webService`, redirecting external traffic from port 80 to the service's internal port 3000.
- The `applyTrafficRule` method is used to enforce this rule.
### Continuous Deployment
Coreflow integrates continuous integration and deployment processes, allowing seamless updates and rollbacks for your services:
```typescript
@ -99,8 +123,13 @@ coreflowInstance.deployService(deploymentConfig).then(() => {
});
```
In the above example:
- A deployment configuration is created for the `userAuthService` using the latest image from the specified registry.
- The `deployService` method is then used to deploy the service using the specified update policy (e.g., rolling updates or recreating the service).
### Observability and Monitoring
To keep track of your applications' health and performances, Coreflow provides tools for logging, monitoring, and alerting.
To keep track of your applications' health and performance, Coreflow provides tools for logging, monitoring, and alerting.
```typescript
coreflowInstance.monitorService("webService").on('serviceHealthUpdate', (healthStatus) => {
@ -108,5 +137,202 @@ coreflowInstance.monitorService("webService").on('serviceHealthUpdate', (healthS
});
```
By following these examples, you can utilize Coreflow to manage Docker-based applications, ensuring scalability, reliability, and efficiency across your infrastructure.
In the above example:
- The `monitorService` method is used to monitor the health status of the `webService`.
- When a health update event is received, it is logged to the console.
### Detailed Example: Setting Up and Managing Coreflow
Here is a detailed example that covers various features, from setup to scaling and traffic management.
#### Step 1: Initialize Coreflow
```typescript
import { Coreflow } from '@serve.zone/coreflow';
const coreflowInstance = new Coreflow();
async function initializeCoreflow() {
await coreflowInstance.start();
console.log('Coreflow initialized.');
await manageServices();
}
initializeCoreflow().catch((error) => {
console.error('Error initializing Coreflow:', error);
});
```
#### Step 2: Handling Docker Events
```typescript
coreflowInstance.handleDockerEvents().then(() => {
console.log('Docker events are being handled.');
});
```
#### Step 3: Configuring and Connecting to a Service
```typescript
const serviceConnection = coreflowInstance.createServiceConnection({
serviceName: "databaseService",
servicePort: 5432
});
serviceConnection.connect().then(() => {
console.log('Successfully connected to the database service.');
});
```
#### Step 4: Applying a Scaling Policy
```typescript
const scalingPolicy = {
serviceName: "microserviceA",
replicaCount: 3, // Starting with 3 replicas
maxReplicaCount: 10, // Allowing up to 10 replicas
minReplicaCount: 2, // Ensuring at least 2 replicas
};
coreflowInstance.applyScalingPolicy(scalingPolicy).then(() => {
console.log('Scaling policy applied for microserviceA');
});
```
#### Step 5: Managing Network Traffic
```typescript
import { TrafficRule } from '@serve.zone/coreflow';
const trafficRules: TrafficRule[] = [
{
serviceName: "frontendService",
externalPort: 80,
internalPort: 3000,
protocol: "http",
},
{
serviceName: "apiService",
externalPort: 443,
internalPort: 4000,
protocol: "https",
}
];
Promise.all(trafficRules.map((rule) => coreflowInstance.applyTrafficRule(rule))).then(() => {
console.log('Traffic rules applied.');
});
```
#### Step 6: Deploying a Service
```typescript
const deploymentConfig = {
serviceName: "authService",
image: "myregistry.com/authservice:latest",
updatePolicy: "rolling", // Performing rolling updates
};
coreflowInstance.deployService(deploymentConfig).then(() => {
console.log('AuthService deployed successfully.');
});
```
#### Step 7: Monitoring a Service
```typescript
coreflowInstance.monitorService("frontendService").on('serviceHealthUpdate', (healthStatus) => {
console.log(`Health update for frontendService: ${healthStatus}`);
});
```
### Advanced Usage: Task Scheduling and Traffic Configuration
In more complex scenarios, you might want to leverage Coreflow's ability to schedule tasks and manage traffic configurations.
#### Scheduling Tasks
Coreflow supports scheduling updates and other tasks using the `taskBuffer` API.
```typescript
import { Task } from '@push.rocks/taskbuffer';
const checkinTask = new Task({
name: 'checkin',
buffered: true,
taskFunction: async () => {
console.log('Running checkin task...');
}
});
const taskManager = coreflowInstance.taskManager;
taskManager.addAndScheduleTask(checkinTask, '0 * * * * *'); // Scheduling task to run every minute
taskManager.start().then(() => {
console.log('Task manager started.');
});
```
#### Managing Traffic Routing
Coreflow can manage complex traffic routing scenarios, such as configuring reverse proxies for different services.
```typescript
import { CoretrafficConnector } from '@serve.zone/coreflow';
// Assume coreflowInstance is already started
const coretrafficConnector = new CoretrafficConnector(coreflowInstance);
const reverseProxyConfigs = [
{
hostName: "example.com",
destinationIp: "192.168.1.100",
destinationPort: "3000",
privateKey: "<your-private-key>",
publicKey: "<your-public-key>",
},
{
hostName: "api.example.com",
destinationIp: "192.168.1.101",
destinationPort: "4000",
privateKey: "<your-private-key>",
publicKey: "<your-public-key>",
},
];
coretrafficConnector.setReverseConfigs(reverseProxyConfigs).then(() => {
console.log('Reverse proxy configurations applied.');
});
```
### Integrating with Cloudly
Coreflow is designed to integrate seamlessly with Cloudly, a configuration management and orchestration tool.
#### Starting the Cloudly Connector
```typescript
const cloudlyConnector = coreflowInstance.cloudlyConnector;
cloudlyConnector.start().then(() => {
console.log('Cloudly connector started.');
});
```
#### Retrieving and Applying Configurations from Cloudly
```typescript
cloudlyConnector.getConfigFromCloudly().then((config) => {
console.log('Received configuration from Cloudly:', config);
coreflowInstance.clusterManager.provisionWorkloadServices(config).then(() => {
console.log('Workload services provisioned based on Cloudly config.');
});
});
```
### Conclusion
Coreflow is a powerful and flexible tool for managing Docker-based applications, scaling services, configuring network traffic, handling continuous deployments, and ensuring observability of your infrastructure. The examples provided aim to give a comprehensive understanding of how to use Coreflow in various scenarios, ensuring it meets your DevOps and CI/CD needs.
By leveraging Coreflow's rich feature set, you can optimize your infrastructure for high availability, scalability, and efficient operation across multiple servers and environments.
undefined

View File

@ -1,8 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@serve.zone/coreflow',
version: '1.0.132',
description: 'A comprehensive solution for managing Docker and scaling applications across servers, handling tasks from service provisioning to network traffic management.'
version: '1.0.133',
description: 'A comprehensive tool for managing Docker-based applications and services, enabling efficient scaling, network management, and integration with cloud services.'
}

View File

@ -28,14 +28,12 @@ export class ClusterManager {
*/
public async start() {
const config = await this.coreflowRef.cloudlyConnector.getConfigFromCloudly();
await this.setDockerAuth(config);
this.readyDeferred.resolve();
// subscriptions
this.configSubscription =
this.coreflowRef.cloudlyConnector.cloudlyClient.configUpdateSubject.subscribe(
async (dataArg) => {
await this.setDockerAuth(dataArg.configData);
this.coreflowRef.taskManager.updateBaseServicesTask.trigger();
}
);
@ -63,10 +61,6 @@ export class ClusterManager {
this.configSubscription ? this.configSubscription.unsubscribe() : null;
}
public async setDockerAuth(configArg: plugins.servezoneInterfaces.data.IClusterConfig) {
await this.dockerHost.auth(configArg.data.registryInfo);
}
/**
* provisions base services
*/
@ -191,7 +185,11 @@ export class ClusterManager {
/**
* provision services obtained from cloudly
*/
public async provisionWorkloadServices(configData: plugins.servezoneInterfaces.data.IClusterConfig) {
public async provisionWorkloadServices(configData: plugins.servezoneInterfaces.data.ICluster) {
// lets get the config + deploymentDirectives
for (const containerConfig of configData.data.containers) {
await this.provisionSpecificWorkloadService(containerConfig);
}

View File

@ -1,12 +1,12 @@
import * as loleLog from '@losslessone_private/lole-log';
import * as plugins from './coreflow.plugins.js';
import { projectInfoNpm } from './coreflow.info.js';
export const logger = loleLog.createLoleLogger({
companyUnit: 'Lossless Cloud',
export const logger = new plugins.smartlog.Smartlog({
logContext: {
containerName: 'coreflow',
containerVersion: projectInfoNpm.version,
sentryAppName: 'coreflow',
sentryDsn: 'https://2a449cd768b34a1b9b5ec34845b4bbd0@sentry.io/1762080',
environment: 'production',
runtime: 'node',
zone: 'servezone',
},
});
logger.enableConsole();