mirror of
https://github.com/redlib-org/redlib.git
synced 2025-06-21 08:30:57 +00:00
I hate workflows
Lets see if gpt can fix it
This commit is contained in:
parent
04d8aceac1
commit
18a1c677c7
2 changed files with 44 additions and 36 deletions
47
.github/workflows/build-and-push.yml
vendored
47
.github/workflows/build-and-push.yml
vendored
|
@ -1,39 +1,34 @@
|
||||||
name: Build and Push Docker Image
|
name: Build and Deploy Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
workflow_dispatch: # Allows manual trigger
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY_IMAGE: luciferscircle/redlib
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
- name: Log in to DockerHub
|
- name: Cache Docker layers
|
||||||
uses: docker/login-action@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
path: /tmp/.buildx-cache
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
key: ${{ runner.os }}-docker-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-docker-
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build Docker image
|
||||||
uses: docker/build-push-action@v5
|
run: |
|
||||||
with:
|
docker build --file Dockerfile --tag luciferscircle/webos-token-refresh .
|
||||||
context: .
|
|
||||||
platforms: linux/amd64
|
- name: Push Docker image
|
||||||
push: true
|
run: |
|
||||||
tags: |
|
docker push luciferscircle/webos-token-refresh
|
||||||
${{ env.REGISTRY_IMAGE }}:latest
|
|
||||||
${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
|
|
||||||
build-args: |
|
|
||||||
TARGET=x86_64-unknown-linux-musl
|
|
||||||
|
|
33
Dockerfile
33
Dockerfile
|
@ -1,23 +1,36 @@
|
||||||
FROM rust:1.71.0-alpine
|
# Use an Alpine-based image as the base
|
||||||
|
FROM rust:1.71.0-alpine3.19 AS build
|
||||||
|
|
||||||
# Install git and other necessary dependencies using apk
|
# Install necessary dependencies (git, curl, etc.)
|
||||||
RUN apk update && apk add --no-cache git
|
RUN apk add --no-cache git curl build-base
|
||||||
|
|
||||||
# Set the working directory to /build
|
# Set the working directory for the build process
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
# Clone the redlib repository
|
# Clone the repository
|
||||||
RUN git clone https://github.com/LucifersCircle/redlib.git /build
|
RUN git clone https://github.com/LucifersCircle/redlib.git .
|
||||||
|
|
||||||
# Checkout the main branch
|
# Build the project using Cargo
|
||||||
RUN cd /build && git checkout main
|
RUN cargo build --release
|
||||||
|
|
||||||
# Set the final image's default user
|
# Final image with only the necessary runtime dependencies
|
||||||
|
FROM alpine:3.19
|
||||||
|
|
||||||
|
# Install dependencies needed to run the binary (curl, for healthcheck)
|
||||||
|
RUN apk add --no-cache curl
|
||||||
|
|
||||||
|
# Copy the compiled binary from the build stage
|
||||||
|
COPY --from=build /build/target/release/redlib /usr/local/bin/
|
||||||
|
|
||||||
|
# Add a user to run the application
|
||||||
RUN adduser --home /nonexistent --no-create-home --disabled-password redlib
|
RUN adduser --home /nonexistent --no-create-home --disabled-password redlib
|
||||||
USER redlib
|
USER redlib
|
||||||
|
|
||||||
# Expose the necessary port
|
# Expose the necessary port
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
# Set the default command to run the application
|
# Run a healthcheck to ensure the app is working
|
||||||
|
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider -q http://localhost:8080/settings || exit 1
|
||||||
|
|
||||||
|
# Set the default command to run the redlib binary
|
||||||
CMD ["redlib"]
|
CMD ["redlib"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue