Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Start from a Rust base image
FROM rust:1.79-bullseye as builder

# Create a new empty shell project
RUN USER=root cargo new --bin recent-messages2
WORKDIR /recent-messages2

# Copy over your manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
COPY ./rust-toolchain.toml ./rust-toolchain.toml

# Copy your source tree
COPY ./src ./src
COPY ./migrations_main ./migrations_main
COPY ./migrations_shard ./migrations_shard

# Build for release.
RUN cargo build --release

# Our second stage, that will be the final image
FROM debian:bullseye-slim
WORKDIR /app

# Install libssl (needed for most applications)
RUN apt-get update && apt-get install -y libssl-dev && rm -rf /var/lib/apt/lists/*

# Copy the build artifact from the builder stage and set the startup command
COPY --from=builder /recent-messages2/target/release/recent-messages2 .
COPY config.toml .

# Create a directory for messages
RUN mkdir /app/messages

# Start the binary
CMD ["./recent-messages2"]
22 changes: 22 additions & 0 deletions deployments/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: recent-messages2-config
data:
config.toml: |
# Paste the contents of your config.toml file here
[app]
channels_expire_after = "2400 hours"
messages_expire_after = "2400 hours"
max_buffer_size = 5000

[web]
# Twitch API access credentials, register an application at https://dev.twitch.tv/
client_id = "abc"
client_secret = "def"
redirect_uri = "http://localhost"

[main_db]
user = "db_username"
dbname = "recent_messages2"
host = [ { hostname = "postgres", port = 5432 } ]
39 changes: 39 additions & 0 deletions deployments/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: recent-messages2
spec:
replicas: 1
selector:
matchLabels:
app: recent-messages2
template:
metadata:
labels:
app: recent-messages2
spec:
containers:
- name: recent-messages2
image: civon/recent-messages2:v0.1
ports:
- containerPort: 8080
volumeMounts:
- name: config-volume
mountPath: /app/config.toml
subPath: config.toml
volumes:
- name: config-volume
configMap:
name: recent-messages2-config
---
apiVersion: v1
kind: Service
metadata:
name: recent-messages2
spec:
selector:
app: recent-messages2
ports:
- protocol: TCP
port: 80
targetPort: 8080
42 changes: 42 additions & 0 deletions deployments/postgres-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:13-alpine
env:
# use these carefully if you expose database to outside world
- name: POSTGRES_USER
value: "db_username"
- name: POSTGRES_DB
value: "recent_messages2"
- name: POSTGRES_HOST_AUTH_METHOD
value: "trust"
- name: POSTGRES_PASSWORD
value: "password"
ports:
- containerPort: 5432
---
# postgres-service.yaml
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
selector:
app: postgres
ports:
- protocol: TCP
port: 5432
targetPort: 5432