Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
backend/Dockerfile at master · perfect-panel/backend · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
perfect-panel
backend
Repository navigation
Code
Issues
36
(36)
Pull requests
2
(2)
Discussions
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
backend
/
Dockerfile
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
78 lines (61 loc) · 3.06 KB
master
Breadcrumbs
backend
/
Dockerfile
Copy path
Top
File metadata and controls
Code
Blame
78 lines (61 loc) · 3.06 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#
Use a smaller base image for the build stage
FROM
golang:1.27.3-alpine AS builder
LABEL
stage=gobuilder
ARG
TARGETARCH
ARG
VERSION=unknown
ARG
CHANNEL=dev
#
UTC RFC 3339 (YYYY-MM-DDTHH:MM:SSZ); empty means the time of the build.
ARG
BUILD_TIME=
ENV
CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH}
#
Combine apk commands into one to reduce layer size
RUN
apk update --no-cache && apk add --no-cache tzdata ca-certificates
WORKDIR
/build
#
Copy go.mod and go.sum first to take advantage of Docker caching
COPY
go.mod go.sum ./
RUN
go mod download
#
Copy the rest of the application code
COPY
. .
#
The writable part of the runtime tree, assembled here because the final
#
image has no shell. etc/ ships an empty configuration: a locally initialized
#
etc/ppanel.yaml holds the JWT secret and database credentials and must never
#
be baked into the image (.dockerignore keeps it out of the build context as
#
well); the server completes it on the first start. logs/ receives the log
#
files (Logger.Path) and cache/ the GeoIP database (GeoIP.Path).
RUN
mkdir -p /out/etc /out/logs /out/cache && : > /out/etc/ppanel.yaml
#
Build the binary with version and build time. script/ldflags.sh defines the
#
injected metadata for every build path (make, this image, the release).
RUN
LDFLAGS=
"$(VERSION="
${VERSION}
" CHANNEL="
${CHANNEL}
" BUILD_TIME="
${BUILD_TIME}
" sh script/ldflags.sh)"
&& \
go build -trimpath -ldflags=
"${LDFLAGS}"
-o /out/ppanel main.go
#
Final minimal image
FROM
scratch
#
Copy CA certificates and timezone data
COPY
--from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY
--from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
ENV
TZ=Asia/Shanghai
#
The binary stays owned by root; only the directories the server writes
#
belong to the unprivileged user it runs as (65532, the conventional
#
"nonroot" id). A volume mounted over one of them must be writable by that
#
id on the first start, when the configuration is completed:
#
chown 65532:65532 etc/ppanel.yaml
COPY
--from=builder /out/ppanel /app/ppanel
COPY
--from=builder --chown=65532:65532 /out/etc /app/etc
COPY
--from=builder --chown=65532:65532 /out/logs /app/logs
COPY
--from=builder --chown=65532:65532 /out/cache /app/cache
#
Set working directory: the configuration, logs and cache paths are relative
#
to it.
WORKDIR
/app
#
The server needs no privileges: it listens on 8080 and writes only under
#
/app. Publish a low port with a port mapping (-p 443:8080) rather than by
#
changing Port, which an unprivileged process cannot bind.
USER
65532:65532
#
Expose the port (optional)
EXPOSE
8080
#
The server's own health probe: it asks the running server over the local
#
listener and exits non-zero when it gets no healthy answer, so the
#
orchestrator restarts or stops routing to a container that is up but not
#
serving. The start period covers the first start's database migration.
HEALTHCHECK
--interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD
[
"/app/ppanel"
,
"healthcheck"
]
#
Specify entry point
ENTRYPOINT
[
"/app/ppanel"
]
CMD
[
"run"
,
"--config"
,
"etc/ppanel.yaml"
]
You can’t perform that action at this time.