Skip to content

Commit 7ece6c6

Browse files
committed
refactor(ci): add docker-build-push job to release ci
1 parent 7ab9a5b commit 7ece6c6

3 files changed

Lines changed: 120 additions & 2 deletions

File tree

.dockerignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.git
2+
.gitignore
3+
.github
4+
5+
rustmail/*
6+
rustmail_panel/
7+
rustmail_types/
8+
target/
9+
**/Cargo.toml
10+
**/Cargo.lock
11+
12+
*.md
13+
LICENSE
14+
docs/
15+
16+
*.yml
17+
*.yaml
18+
19+
*.swp
20+
*.swo
21+
*~
22+
.DS_Store
23+
.vscode
24+
.idea
25+
26+
db/
27+
*.db
28+
*.sqlite
29+
config.toml
30+
31+
rustmail-*.tar.gz
32+
rustmail-*.zip
33+
34+
tests/
35+
**/*_test.rs

.github/workflows/release-ci.yml

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Release
22

33
permissions:
44
contents: write
5+
packages: write
56

67
on:
78
push:
@@ -59,7 +60,7 @@ jobs:
5960
else
6061
prerelease=""
6162
fi
62-
63+
6364
gh release create "$tag" \
6465
--repo="$GITHUB_REPOSITORY" \
6566
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \
@@ -114,4 +115,61 @@ jobs:
114115

115116
zip: windows
116117

117-
token: ${{ secrets.GT_TOKEN }}
118+
token: ${{ secrets.GT_TOKEN }}
119+
120+
docker-build-push:
121+
name: Build and push Docker Image
122+
needs: upload-assets
123+
runs-on: ubuntu-latest
124+
env:
125+
REGISTRY: ghcr.io
126+
IMAGE_NAME: ${{ github.repository }}
127+
steps:
128+
- name: Checkout repository
129+
uses: actions/checkout@v4
130+
131+
- name: Set up Docker Buildx
132+
uses: docker/setup-buildx-action@v3
133+
134+
- name: Log in to GitHub Container Registry
135+
uses: docker/login-action@v3
136+
with:
137+
registry: ${{ env.REGISTRY }}
138+
username: ${{ github.actor }}
139+
password: ${{ secrets.GITHUB_TOKEN }}
140+
141+
- name: Download Linux binary from release
142+
env:
143+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144+
run: |
145+
rm -rf rustmail
146+
147+
gh release download ${{ github.ref_name }} \
148+
--repo ${{ github.repository }} \
149+
--pattern 'rustmail-x86_64-unknown-linux-gnu.tar.gz'
150+
151+
tar -xzf rustmail-x86_64-unknown-linux-gnu.tar.gz
152+
chmod +x rustmail
153+
ls -lh rustmail
154+
155+
- name: Extract metadata for Docker
156+
id: meta
157+
uses: docker/metadata-action@v5
158+
with:
159+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
160+
tags: |
161+
type=semver,pattern={{version}}
162+
type=semver,pattern={{major}}.{{minor}}
163+
type=semver,pattern={{major}}
164+
type=raw,value=latest,enable=${{ !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') }}
165+
166+
- name: Build and push Docker image
167+
uses: docker/build-push-action@v5
168+
with:
169+
context: .
170+
push: true
171+
tags: ${{ steps.meta.outputs.tags }}
172+
labels: ${{ steps.meta.outputs.labels }}
173+
platforms: linux/amd64
174+
cache-from: type=gha
175+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM debian:bookworm-slim
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update && apt-get install -y \
6+
libssl3 \
7+
ca-certificates \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
COPY rustmail /app/rustmail
11+
12+
RUN mkdir -p /app/db && chmod 755 /app/db
13+
14+
RUN chmod +x /app/rustmail
15+
16+
RUN useradd -m -u 1000 rustmail && \
17+
chown -R rustmail:rustmail /app
18+
19+
USER rustmail
20+
21+
EXPOSE 3002
22+
23+
VOLUME ["/app/db", "/app/config.toml"]
24+
25+
ENTRYPOINT ["/app/rustmail"]

0 commit comments

Comments
 (0)