Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
freeGpt-sub2api/Dockerfile at main · sql-agi/freeGpt-sub2api · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
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 }}
sql-agi
freeGpt-sub2api
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
freeGpt-sub2api
/
Dockerfile
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
137 lines (109 loc) · 4.69 KB
main
Breadcrumbs
freeGpt-sub2api
/
Dockerfile
Copy path
Top
File metadata and controls
Code
Blame
137 lines (109 loc) · 4.69 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#
=============================================================================
#
Sub2API Multi-Stage Dockerfile
#
=============================================================================
#
Stage 1: Build frontend
#
Stage 2: Build Go backend with embedded frontend
#
Stage 3: Final minimal image
#
=============================================================================
ARG
NODE_IMAGE=node:24-alpine
ARG
GOLANG_IMAGE=golang:1.26.2-alpine
ARG
ALPINE_IMAGE=alpine:3.21
ARG
POSTGRES_IMAGE=postgres:18-alpine
ARG
GOPROXY=https://goproxy.cn,direct
ARG
GOSUMDB=sum.golang.google.cn
#
-----------------------------------------------------------------------------
#
Stage 1: Frontend Builder
#
-----------------------------------------------------------------------------
FROM
${NODE_IMAGE} AS frontend-builder
WORKDIR
/app/frontend
#
Install pnpm
RUN
corepack enable && corepack prepare pnpm@latest --activate
#
Install dependencies first (better caching)
COPY
frontend/package.json frontend/pnpm-lock.yaml ./
RUN
pnpm install --frozen-lockfile
#
Copy frontend source and build
COPY
frontend/ ./
RUN
pnpm run build
#
-----------------------------------------------------------------------------
#
Stage 2: Backend Builder
#
-----------------------------------------------------------------------------
FROM
${GOLANG_IMAGE} AS backend-builder
#
Build arguments for version info (set by CI)
ARG
VERSION=
ARG
COMMIT=docker
ARG
DATE
ARG
GOPROXY
ARG
GOSUMDB
ENV
GOPROXY=${GOPROXY}
ENV
GOSUMDB=${GOSUMDB}
#
Install build dependencies
RUN
apk add --no-cache git ca-certificates tzdata
WORKDIR
/app/backend
#
Copy go mod files first (better caching)
COPY
backend/go.mod backend/go.sum ./
RUN
go mod download
#
Copy backend source first
COPY
backend/ ./
#
Copy frontend dist from previous stage (must be after backend copy to avoid being overwritten)
COPY
--from=frontend-builder /app/backend/internal/web/dist ./internal/web/dist
#
Build the binary (BuildType=release for CI builds, embed frontend)
#
Version precedence: build arg VERSION > cmd/server/VERSION
RUN
VERSION_VALUE=
"${VERSION}"
&& \
if [ -z
"${VERSION_VALUE}"
]; then VERSION_VALUE=
"$(tr -d '
\r\n
' < ./cmd/server/VERSION)"
; fi && \
DATE_VALUE=
"${DATE:-$(date -u +%Y-%m-%dT%H:%M:%SZ)}"
&& \
CGO_ENABLED=0 GOOS=linux go build \
-tags embed \
-ldflags=
"-s -w -X main.Version=${VERSION_VALUE} -X main.Commit=${COMMIT} -X main.Date=${DATE_VALUE} -X main.BuildType=release"
\
-trimpath \
-o /app/sub2api \
./cmd/server
#
-----------------------------------------------------------------------------
#
Stage 3: PostgreSQL Client (version-matched with docker-compose)
#
-----------------------------------------------------------------------------
FROM
${POSTGRES_IMAGE} AS pg-client
#
-----------------------------------------------------------------------------
#
Stage 4: Final Runtime Image
#
-----------------------------------------------------------------------------
FROM
${ALPINE_IMAGE}
#
Labels
LABEL
maintainer=
"Wei-Shaw <github.com/Wei-Shaw>"
LABEL
description=
"Sub2API - AI API Gateway Platform"
LABEL
org.opencontainers.image.source=
"https://github.com/Wei-Shaw/sub2api"
#
Install runtime dependencies
RUN
apk add --no-cache \
ca-certificates \
tzdata \
su-exec \
libpq \
zstd-libs \
lz4-libs \
krb5-libs \
libldap \
libedit \
&& rm -rf /var/cache/apk/*
#
Copy pg_dump and psql from the same postgres image used in docker-compose
#
This ensures version consistency between backup tools and the database server
COPY
--from=pg-client /usr/local/bin/pg_dump /usr/local/bin/pg_dump
COPY
--from=pg-client /usr/local/bin/psql /usr/local/bin/psql
COPY
--from=pg-client /usr/local/lib/libpq.so.5* /usr/local/lib/
#
Create non-root user
RUN
addgroup -g 1000 sub2api && \
adduser -u 1000 -G sub2api -s /bin/sh -D sub2api
#
Set working directory
WORKDIR
/app
#
Copy binary/resources with ownership to avoid extra full-layer chown copy
COPY
--from=backend-builder --chown=sub2api:sub2api /app/sub2api /app/sub2api
COPY
--from=backend-builder --chown=sub2api:sub2api /app/backend/resources /app/resources
#
Create data directory
RUN
mkdir -p /app/data && chown sub2api:sub2api /app/data
#
Copy entrypoint script (fixes volume permissions then drops to sub2api)
COPY
deploy/docker-entrypoint.sh /app/docker-entrypoint.sh
RUN
chmod +x /app/docker-entrypoint.sh
#
Expose port (can be overridden by SERVER_PORT env var)
EXPOSE
8080
#
Health check
HEALTHCHECK
--interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD
wget -q -T 5 -O /dev/null http://localhost:${SERVER_PORT:-8080}/health || exit 1
#
Run the application (entrypoint fixes /app/data ownership then execs as sub2api)
ENTRYPOINT
[
"/app/docker-entrypoint.sh"
]
CMD
[
"/app/sub2api"
]
You can’t perform that action at this time.