### Deploying a Docker Container with ASTRA
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-docker/README.md
Defines an ASTRA agent that deploys a specified Docker image, including initial image and binding beliefs, and a rule to start the container.
```Astra
agent MyAgent extends Docker {
constant string TIC_TAC_TOE = "registry.gitlab.com/mams-ucd/examples/semantic-environments/tic-tac-toe" ;
initial image(TIC_TAC_TOE);
initial binding(TIC_TAC_TOE, "8083:8083");
rule +!main(list args) {
!container(TIC_TAC_TOE, string id);
}
}
```
--------------------------------
### Declaring a Docker Image Belief
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-docker/README.md
Shows how to declare an initial belief for a Docker image, using a fully qualified name.
```Astra
initial image("registry.gitlab.com/mams-ucd/examples/semantic-environments/tic-tac-toe");
```
--------------------------------
### Declaring a Docker Image Belief (Short Name)
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-docker/README.md
Demonstrates declaring an initial belief for a Docker image using a less qualified name for public repositories.
```Astra
initial image("arm64v8/hello-world");
```
--------------------------------
### Using a Constant for Docker Image Name
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-docker/README.md
Illustrates defining a constant for a Docker image name and then using it to declare the image belief.
```Astra
constant string TIC_TAC_TOE = "registry.gitlab.com/mams-ucd/examples/semantic-environments/tic-tac-toe";
initial image(TIC_TAC_TOE);
```
--------------------------------
### Deploy ASTRA Agent with Maven
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-maven-plugin/README.md
Manually invoke the ASTRA deploy goal to run your ASTRA agent program. This is not integrated into the default Jar lifecycle.
```bash
$ mvn astra:deploy
```
--------------------------------
### Declaring Repository URL Belief
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-docker/README.md
Shows how to declare the repository URL belief for a named Docker image, which is necessary for authenticated access.
```Astra
initial repository(TIC_TAC_TOE, "registry.gitlab.com");
```
--------------------------------
### Generate ASTRA Project with Maven Archetype
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-cartago-archetype/README.md
Use the Maven archetype plugin to generate a new ASTRA project with default settings and a sample agent.
```bash
mvn archetype:generate \
-DarchetypeGroupId=astra \
-DarchetypeArtifactId=astra-archetype \
-DarchetypeVersion=0.1.0 \
-DgroupId=test \
-DartifactId=tester \
-Dversion=0.1.0
```
--------------------------------
### Docker Credentials File Format
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-docker/README.md
Provides the format for a Docker credentials file, used for secure access to private repositories. Each line contains repository URL, username, and passkey delimited by colons.
```Text
MY_REPOSITORY:MY_USERNAME:MY-PASS-KEY
MY_OTHER_REPOSITORY:MY_OTHER_USERNAME:MY-OTHER-PASS-KEY
```
--------------------------------
### Declaring Port Binding Belief
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-docker/README.md
Illustrates how to declare a port binding belief to make a service within a Docker container accessible externally.
```Astra
initial binding(TIC_TAC_TOE, "8083:8083");
```
--------------------------------
### Maven Project Object Model (pom.xml) Configuration
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-maven-plugin/README.md
Include this plugin configuration in your pom.xml to enable ASTRA compilation and testing within the Maven build lifecycle. Set 'mainClass' and 'mainName' for custom program entry points and agent names.
```xml
com.astralanguage
astra-maven-plugin
1.0.0
${astra.main}
${astra.name}
astra.compile
compile
compile
astra.test
test-compile
testCompile
astra.testrun
test
test
```
--------------------------------
### Declaring Username Belief for Repository
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-docker/README.md
Demonstrates declaring the username belief associated with a specific Docker image and repository, required for authentication.
```Astra
initial username(TIC_TAC_TOE, "MY_USERNAME");
```
--------------------------------
### Add Credentials to File
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-docker/README.md
Use this snippet to add credentials directly to the credentials file for Docker image pulls.
```astra
agent Test extends Docker {
rule +!main(list args) {
credentials.add("MY_REPOSITORY", "MY_USERNAME", "MY_PASSKEY");
}
}
```
--------------------------------
### Test ASTRA Code with Maven
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-maven-plugin/README.md
Invoke the Maven test phase to run tests for your ASTRA agent programs. This leverages the plugin's test execution goals.
```bash
$ mvn test
```
--------------------------------
### Declaring Shared Volume Belief
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-docker/README.md
Shows how to declare a volume belief to map a local folder to a folder within the Docker container, enabling data persistence or access.
```Astra
initial volume(TIC_TAC_TOE, "/target", "/test");
```
--------------------------------
### Compile ASTRA Code with Maven
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-maven-plugin/README.md
Invoke the Maven compile phase to compile your ASTRA agent programs. This integrates with the standard Maven build process.
```bash
$ mvn compile
```
--------------------------------
### Bypass Credentials Module with Custom Rules
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-docker/README.md
Implement custom rules to manage Docker authentication without relying on the default credentials module. This forces the agent to use the specified authentication when pulling images.
```astra
agent Test extends Docker {
rule +?local(string name) {
AuthConfig authConfig = docker.createAuthConfig(
"MY_REPOSITORY",
"MY_USERNAME",
"MY_PASSKEY"
);
docker.auth(authConfig);
+authConfig(name, authConfig);
?local(name);
}
}
```
--------------------------------
### Child POM Configuration for Astra Projects
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-base/README.md
Include this XML configuration in your child POM to inherit from the astra-base parent POM and configure the astra-maven-plugin.
```xml
4.0.0
{group-id}
{project-id}
{version-num}
astra-repo
https://gitlab.com/astra-language/astra-mvn-repo/raw/master
astra
astra-base
0.1.0
astra
astra-maven-plugin
```
--------------------------------
### Add ASTRA Repository to Maven Settings
Source: https://gitlab.com/astra-language/astra-core/-/blob/master/astra-cartago-archetype/README.md
Configure your Maven settings.xml to include the ASTRA repository for dependency resolution.
```xml
astra-repo
ASTRA Maven Repository
https://gitlab.com/astra-language/astra-mvn-repo/raw/master
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.