Skip to content

Commit e58ae64

Browse files
committed
Add dockerfile
1 parent 9c39e36 commit e58ae64

4 files changed

Lines changed: 81 additions & 1 deletion

File tree

.github/workflows/docker.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
- dev
6+
tags:
7+
- "v*.*.*"
8+
pull_request:
9+
branches:
10+
- main
11+
- dev
12+
13+
jobs:
14+
build:
15+
name: Build
16+
runs-on: ubuntu-24.04
17+
steps:
18+
- name: Check Out Repo
19+
uses: actions/checkout@v4
20+
- name: Docker metadata
21+
id: metadata
22+
uses: docker/metadata-action@v5
23+
with:
24+
images: |
25+
ghcr.io/${{ github.repository }}
26+
tags: |
27+
type=raw,value=latest,enable={{is_default_branch}}
28+
type=ref,event=branch
29+
type=ref,event=tag
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
- name: Login to GitHub Container Registry
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.repository_owner }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
- name: Build and push
39+
id: docker_build
40+
uses: docker/build-push-action@v5
41+
with:
42+
file: Dockerfile
43+
push: ${{ github.event_name != 'pull_request' }}
44+
tags: ${{ steps.metadata.outputs.tags }}
45+
cache-from: type=gha,scope=main
46+
cache-to: type=gha,mode=max,scope=main
47+
platforms: linux/amd64,linux/arm64

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
/target
2-
.env
2+
3+
# dotenv environment variable files
4+
/.env
5+
/.env.*
6+
!/.env.example

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"cSpell.words": [
33
"actix",
4+
"buildx",
45
"chrono",
56
"codegen",
67
"dotenv",

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM rust:1.91 AS builder
2+
3+
RUN mkdir -p /build
4+
5+
ENV RUST_BACKTRACE=1
6+
ENV SQLX_OFFLINE=true
7+
8+
WORKDIR /build
9+
10+
COPY . /build
11+
12+
RUN --mount=type=cache,target=$CARGO_HOME/git \
13+
--mount=type=cache,target=$CARGO_HOME/registry \
14+
--mount=type=cache,target=/build/target \
15+
cargo build --release && cp /build/target/release/openworkers-logs /build/output
16+
17+
FROM debian:bookworm-slim
18+
19+
RUN apt-get update \
20+
# Install ca-certificates and wget (used for healthcheck)
21+
&& apt-get install -y ca-certificates wget \
22+
&& rm -rf /var/lib/apt/lists/*
23+
24+
COPY --from=builder /build/output /usr/local/bin/openworkers-logs
25+
26+
CMD ["/usr/local/bin/openworkers-logs"]
27+
28+
EXPOSE 8080

0 commit comments

Comments
 (0)