I hate workflows

Lets see if gpt can fix it
This commit is contained in:
LucifersCircle 2024-11-29 03:02:12 -08:00
parent 04d8aceac1
commit 18a1c677c7
2 changed files with 44 additions and 36 deletions

View file

@ -1,39 +1,34 @@
name: Build and Push Docker Image
name: Build and Deploy Docker Image
on:
push:
branches:
- main
workflow_dispatch: # Allows manual trigger
env:
REGISTRY_IMAGE: luciferscircle/redlib
workflow_dispatch:
jobs:
build-and-push:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to DockerHub
uses: docker/login-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: |
${{ env.REGISTRY_IMAGE }}:latest
${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
build-args: |
TARGET=x86_64-unknown-linux-musl
- name: Build Docker image
run: |
docker build --file Dockerfile --tag luciferscircle/webos-token-refresh .
- name: Push Docker image
run: |
docker push luciferscircle/webos-token-refresh

View file

@ -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
RUN apk update && apk add --no-cache git
# Install necessary dependencies (git, curl, etc.)
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
# Clone the redlib repository
RUN git clone https://github.com/LucifersCircle/redlib.git /build
# Clone the repository
RUN git clone https://github.com/LucifersCircle/redlib.git .
# Checkout the main branch
RUN cd /build && git checkout main
# Build the project using Cargo
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
USER redlib
# Expose the necessary port
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"]