Skip to content

Commit 1ce0ef8

Browse files
committed
initial ollama
1 parent 30e09cc commit 1ce0ef8

File tree

9 files changed

+131
-0
lines changed

9 files changed

+131
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM mcr.microsoft.com/devcontainers/python:3.12-bookworm
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"build": {
3+
"dockerfile": "Dockerfile",
4+
"context": ".."
5+
},
6+
"features": {
7+
"ghcr.io/defanglabs/devcontainer-feature/defang-cli:1.0.4": {},
8+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
9+
}
10+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
steps:
16+
- name: Checkout Repo
17+
uses: actions/checkout@v4
18+
19+
- name: Deploy
20+
uses: DefangLabs/[email protected]
21+
#REMOVE_ME_AFTER_EDITING - Replace the following line with the list of environment variables you want to pass to the action
22+
# or remove the lines if you don't need to pass any environment variables/secrets to the action
23+
with:
24+
config-env-vars: ENV1 ENV2
25+
env:
26+
ENV1: ${{ secrets.ENV1 }}
27+
ENV2: ${{ secrets.ENV2 }}

samples/ollama/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Starter Sample #REMOVE_ME_AFTER_EDITING
2+
3+
[1-click deploy](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-<YOUR_SAMPLE_DIR#REMOVE_ME_AFTER_EDITING>-template%26template_owner%3DDefangSamples)
4+
5+
This is a sample that shows the rough structure of an actual Defang sample. This top paragraph should give a bit of context about the project and what it does. The rest of the README should be a guide on how to use the sample. #REMOVE_ME_AFTER_EDITING
6+
7+
## Prerequisites
8+
9+
1. [!NOTE] Download [Defang CLI](https://github.com/DefangLabs/defang)
10+
2. (Optional) If you are using [Defang BYOC](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) authenticated with your AWS account
11+
3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)
12+
13+
## Development
14+
15+
To run the application locally, you can use the following command:
16+
17+
```bash
18+
# This might be `docker compose -f compose.dev.yaml up` depending on the project. #REMOVE_ME_AFTER_EDITING
19+
docker compose up
20+
```
21+
22+
## Configuration
23+
#REMOVE_ME_AFTER_EDITING - this section should be removed if there are no configuration values needed. The intro text can probably stay, but the list of configuration values should be updated/removed if there are none.
24+
25+
For this sample, you will need to provide the following [configuration](https://docs.defang.io/docs/concepts/configuration). Note that if you are using the 1-click deploy option, you can set these values as secrets in your GitHub repository and the action will automatically deploy them for you.
26+
27+
### `API_KEY` #REMOVE_ME_AFTER_EDITING
28+
An explanation of what the env var (`API_KEY`) is, etc.
29+
30+
## Deployment
31+
32+
> [!NOTE]
33+
> Download [Defang CLI](https://github.com/DefangLabs/defang)
34+
35+
### Defang Playground
36+
37+
Deploy your application to the defang playground by opening up your terminal and typing `defang up`.
38+
39+
### BYOC (AWS)
40+
41+
If you want to deploy to your own cloud account, you can use Defang BYOC:
42+
43+
1. [Authenticate your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), and that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`.
44+
2. Run `defang up` in a terminal that has access to your AWS environment variables.
45+
46+
---
47+
48+
Title: Sample Title #REMOVE_ME_AFTER_EDITING
49+
50+
Short Description: A short sentence or two describing the sample. #REMOVE_ME_AFTER_EDITING
51+
52+
Tags: Tags, That, Are, Not, Programming, Languages #REMOVE_ME_AFTER_EDITING
53+
54+
Languages: Programming, Languages, Used #REMOVE_ME_AFTER_EDITING

samples/ollama/app/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

samples/ollama/app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

samples/ollama/app/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ubuntu:22.04
2+
3+
# install curl
4+
RUN apt-get update && apt-get install -y curl && apt-get clean
5+
6+
# create ollama user and group
7+
RUN groupadd -r ollama && useradd -r -g ollama ollama
8+
9+
RUN curl -fsSL https://ollama.com/install.sh | sh
10+
11+
COPY ./run /run
12+
13+
USER ollama
14+
15+
CMD ["/run"]

samples/ollama/app/run

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
ollama pull llama3.2:1b
4+

samples/ollama/compose.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Sample compose file. #REMOVE_ME_AFTER_EDITING
2+
3+
services:
4+
app:
5+
# uncomment to add your own domain
6+
# domainname: example.com
7+
build:
8+
context: ./app
9+
dockerfile: Dockerfile
10+
ports:
11+
- target: 3000
12+
published: 3000
13+
mode: ingress
14+
healthcheck:
15+
# wget or curl required for healthchecks on services with a published port
16+
# this gets parsed by Defang and provided to the load balancers as well
17+
test: [ "CMD", "curl", "-s", "http://localhost:3000/" ]

0 commit comments

Comments
 (0)