Skip to content

Commit

Permalink
added ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ParzivalEugene committed May 6, 2024
1 parent 61783f5 commit aa24e5a
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target/
LICENSE.md
README.md
.env
21 changes: 21 additions & 0 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Docker Image CI for GHCR

on:
push:
branches:
- production

jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Login to GitHub Container Registry
run: echo "${{ secrets.GH_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build the Docker image
run: docker build . -t ghcr.io/heliosshieldproject/${{ github.repository }}:${{ github.sha }}

- name: Push the Docker image
run: docker push ghcr.io/heliosshieldproject/${{ github.repository }}:${{ github.sha }}
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM clux/muslrust:stable AS chef
ARG LOGGER_PORT
RUN cargo install cargo-chef
WORKDIR /logger

FROM chef AS planner
COPY . .
CMD [ "mv", ".env.production", ".env" ]
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /logger/recipe.json recipe.json
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
COPY . .
CMD [ "mv", ".env.production", ".env" ]
RUN cargo build --release --target x86_64-unknown-linux-musl

FROM scratch
LABEL org.opencontainers.image.source https://github.com/HeliosShieldProject/logger-rust
COPY --from=builder /logger/target/x86_64-unknown-linux-musl/release/logger /logger
COPY --from=builder /logger/.env.production .env
ENTRYPOINT ["/logger"]
EXPOSE $LOGGER_PORT
59 changes: 59 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "logger"

services:
logger:
build:
context: .
args:
- LOGGER_PORT=${LOGGER_PORT}
dockerfile: Dockerfile
ports:
- "${LOGGER_PORT}:${LOGGER_PORT}"
env_file:
- .env.production
depends_on:
- logs-database
networks:
- logger-network

logs-database:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: ${LOGS_DATABASE_USER}
MONGO_INITDB_ROOT_PASSWORD: ${LOGS_DATABASE_PASSWORD}
volumes:
- logs-database-volume:/data/db
command:
- --port
- ${LOGS_DATABASE_PORT}
ports:
- "${LOGS_DATABASE_PORT}:${LOGS_DATABASE_PORT}"
env_file:
- .env.production
networks:
- logger-network

logs-viewer:
image: mongo-express
restart: always
ports:
- ${LOGS_VIEWER_PORT}:8081
environment:
ME_CONFIG_MONGODB_URL: ${MONGO_URL}
ME_CONFIG_OPTIONS_EDITORTHEME: nord
ME_CONFIG_BASICAUTH_USERNAME: ${LOGS_VIEWER_USER}
ME_CONFIG_BASICAUTH_PASSWORD: ${LOGS_VIEWER_PASSWORD}
env_file:
- .env.production
depends_on:
- logs-database
networks:
- logger-network

volumes:
logs-database-volume:

networks:
logger-network:
external: true

0 comments on commit aa24e5a

Please sign in to comment.