Fixed docker container linking

This commit is contained in:
2023-07-06 10:59:41 -04:00
parent f94b3fe419
commit a352341d3d
8 changed files with 29 additions and 38 deletions

View File

@@ -1,5 +1,5 @@
DISCORD_TOKEN= DISCORD_TOKEN=
RUST_LOG=warn,siren=info RUST_LOG=warn,siren=info
POSTGRES_USER= POSTGRES_USER=siren
POSTGRES_PASSWORD= POSTGRES_PASSWORD=
POSTGRES_DB= POSTGRES_DB=siren

View File

@@ -1 +1 @@
export SIREN_VERSION=0.2.0 SIREN_VERSION=0.2.1

2
Cargo.lock generated
View File

@@ -1372,7 +1372,7 @@ dependencies = [
[[package]] [[package]]
name = "siren" name = "siren"
version = "0.2.0" version = "0.2.1"
dependencies = [ dependencies = [
"dotenv", "dotenv",
"env_logger", "env_logger",

View File

@@ -1,10 +1,8 @@
[package] [package]
name = "siren" name = "siren"
version = "0.2.0" version = "0.2.1"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dotenv = "0.15.0" dotenv = "0.15.0"
serde_json = "1.0" serde_json = "1.0"

View File

@@ -9,12 +9,12 @@ WORKDIR /packages
RUN apt-get update && apt-get install -y curl tar xz-utils RUN apt-get update && apt-get install -y curl tar xz-utils
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux > yt-dlp && \ RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux > yt-dlp && \
chmod +x yt-dlp chmod +x yt-dlp
RUN curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/latest/download/ffmpeg-master-latest-linux64-gpl.tar.xz > ffmpeg.tar.xz && \ RUN curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz > ffmpeg.tar.xz && \
tar -xJf ffmpeg.tar.xz --wildcards */bin/ffmpeg --transform='s/^.*\///' && rm ffmpeg.tar.xz tar -xJf ffmpeg.tar.xz --wildcards */bin/ffmpeg --transform='s/^.*\///' && rm ffmpeg.tar.xz
FROM debian:bullseye-slim as runtime FROM debian:bullseye-slim as runtime
WORKDIR /siren WORKDIR /siren
RUN apt-get update && apt-get install -y libopus-dev ffmpeg youtube-dl RUN apt-get update && apt-get install -y libopus-dev ffmpeg youtube-dl
COPY --from=builder /siren/target/release/siren siren COPY --from=builder /siren/target/release/siren /usr/local/bin/siren
COPY --from=packages /packages /usr/bin COPY --from=packages /packages /usr/bin
CMD ["./siren"] CMD ["siren"]

View File

@@ -1,32 +1,26 @@
#!make
SHELL := /bin/bash SHELL := /bin/bash
include .version
include .env include .env
include .version
export $(shell sed 's/=.*//' .env)
export $(shell sed 's/=.*//' .version)
.PHONY: help build test up down exec clean
build: build:
# if docker inspect siren > /dev/null 2>&1; then docker rmi siren; fi; docker-compose build docker build -t siren:${SIREN_VERSION} .
docker build -t siren .
test: test:
# docker run --rm -it siren:latest bash docker run --env-file .env -it --rm --name siren siren:${SIREN_VERSION}
docker run --env-file .env -it --rm --name siren siren:latest
up: up:
if [[ ! $$(docker images -q siren 2> /dev/null) ]]; then docker-compose build; fi; \ docker compose up -d
docker-compose up -d
down: down:
docker-compose down docker compose down
exec: exec:
docker exec -it siren bash docker exec -it siren bash
clean: clean:
docker rmi siren docker rmi siren
deploy:
@echo "Deploying application..."
@mvn clean deploy || { \
echo "Deployment failed!"; \
exit 1; \
}
@echo "Deployment successful!"

View File

@@ -21,8 +21,8 @@ https://discord.com/api/oauth2/authorize?client_id=<CLIENT_ID>&permissions=40671
- The CLIENT_ID can be found in the General Information tab on the Discord Developer Portal for your application, under `Application ID` - The CLIENT_ID can be found in the General Information tab on the Discord Developer Portal for your application, under `Application ID`
1. Copy `.env.TEMPLATE` to `.env` and fill out the fields 1. Copy `.env.TEMPLATE` to `.env` and fill out the fields
2. Start the application with `docker compose up -d` 2. Build the [Docker](https://www.docker.com/) application with `make build`
- Requires [Docker](https://www.docker.com/) 3. Start the application with `make up`
## Contributing ## Contributing
[Rust](https://www.rust-lang.org/) must be installed to run locally. See [serenity-rs/serenity](https://github.com/serenity-rs/serenity) for more information about Rust Discord API Library. [Rust](https://www.rust-lang.org/) must be installed to run locally. See [serenity-rs/serenity](https://github.com/serenity-rs/serenity) for more information about Rust Discord API Library.
@@ -40,6 +40,6 @@ Begin the application with `cargo run`
The application can also be tested from within a Docker container: The application can also be tested from within a Docker container:
``` ```
docker build -t siren . docker build -t siren:latest .
docker run --env-file .env -it --rm --name siren siren:latest docker run --env-file .env -it --rm --name siren siren:latest
``` ```

View File

@@ -2,31 +2,30 @@ version: '3'
services: services:
siren: siren:
image: siren image: siren:${SIREN_VERSION}
container_name: siren container_name: siren
build: build:
context: . context: .
dockerfile: ./Dockerfile dockerfile: ./Dockerfile
args: args:
- VERSION=${SIREN_VERSION} - VERSION=${SIREN_VERSION}
volumes: #volumes:
- ./app:/usr/src/siren # - ./app:/siren
environment: environment:
DISCORD_TOKEN: ${DISCORD_TOKEN} DISCORD_TOKEN: ${DISCORD_TOKEN}
DATABASE_URL: jdbc:postgresql://db:5432/${POSTGRES_DB} DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db/${POSTGRES_DB}
DATABASE_USERNAME: ${POSTGRES_USER}
DATABASE_PASSWORD: ${POSTGRES_PASSWORD}
depends_on: depends_on:
- db - db
restart: unless-stopped restart: unless-stopped
db: db:
image: postgres:latest image: postgres:latest
container_name: siren_db
environment: environment:
POSTGRES_USER: ${POSTGRES_USER} POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB} POSTGRES_DB: ${POSTGRES_DB}
volumes: #volumes:
- ./data:/var/lib/postgresql/data # - ./data:/var/lib/postgresql/data
ports: ports:
- "5432:5432" - "5432:5432"
restart: unless-stopped restart: unless-stopped