Skip to content

Commit

Permalink
chore: docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
hUwUtao committed Oct 7, 2024
1 parent fd633aa commit b9358ca
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and Publish Docker Image

on:
push:
branches: [master]
pull_request:
branches: [master]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use the official Rust image as a parent image
FROM rust:slim as builder

# Set the working directory in the container
WORKDIR /usr/src/s3-server

# Copy the Cargo.toml and Cargo.lock files
COPY Cargo.toml Cargo.lock ./

# Copy the source code
COPY src ./src

# Build the application
RUN cargo build --release --bin s3-server

# Use a smaller base image for the final image
FROM debian:buster-slim

# Set the working directory in the container
WORKDIR /usr/local/bin

# Copy the built executable from the builder stage
COPY --from=builder /usr/src/s3-server/target/release/s3-server .

# Expose the port the app runs on
EXPOSE 8014

# Run the binary
CMD ["./s3-server"]

0 comments on commit b9358ca

Please sign in to comment.