Skip to content

Commit 64d773f

Browse files
Merge pull request XmirrorSecurity#284 from SuperChen-CC/docker
feat: add package manager support
2 parents 2f314d2 + 746fb00 commit 64d773f

2 files changed

Lines changed: 116 additions & 12 deletions

File tree

.github/workflows/publish_docker_images.yml

Lines changed: 106 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,110 @@ on:
1515
default: "info"
1616

1717
jobs:
18-
publish-images:
18+
image-matrix:
1919
name: Publish Images
2020
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
include:
24+
# Baseimage
25+
- base: scratch
26+
tag: latest
27+
# Maven: only support lts versions
28+
- base: maven:latest
29+
tag: maven
30+
- base: maven:3-eclipse-temurin-8
31+
tag: maven3-jdk8
32+
- base: maven:3-eclipse-temurin-11
33+
tag: maven3-jdk11
34+
- base: maven:3-eclipse-temurin-17
35+
tag: maven3-jdk17
36+
- base: maven:3-eclipse-temurin-21
37+
tag: maven3-jdk21
38+
# Gradle: only support lts versions
39+
- base: gradle:latest
40+
tag: gradle
41+
- base: gradle:jdk8
42+
tag: gradle-jdk8
43+
- base: gradle:jdk11
44+
tag: gradle-jdk11
45+
- base: gradle:jdk17
46+
tag: gradle-jdk17
47+
- base: gradle:jdk21
48+
tag: gradle-jdk21
49+
# Npm: only support lts versions
50+
- base: node:latest
51+
tag: node
52+
- base: node:14
53+
tag: node14
54+
- base: node:16
55+
tag: node16
56+
- base: node:18
57+
tag: node18
58+
- base: node:20
59+
tag: node20
60+
# php
61+
- base: composer:latest
62+
tag: php
63+
# Ruby
64+
- base: ruby:latest
65+
tag: ruby
66+
- base: ruby:3.3
67+
tag: ruby3.3
68+
- base: ruby:3.2
69+
tag: ruby3.2
70+
- base: ruby:3.1
71+
tag: ruby3.1
72+
- base: ruby:3.0
73+
tag: ruby3.0
74+
- base: ruby:2.7
75+
tag: ruby2.7
76+
# Go
77+
- base: golang:latest
78+
tag: go
79+
- base: golang:1.12
80+
tag: go1.12
81+
- base: golang:1.13
82+
tag: go1.13
83+
- base: golang:1.14
84+
tag: go1.14
85+
- base: golang:1.15
86+
tag: go1.15
87+
- base: golang:1.16
88+
tag: go1.16
89+
- base: golang:1.17
90+
tag: go1.17
91+
- base: golang:1.18
92+
tag: go1.18
93+
- base: golang:1.19
94+
tag: go1.19
95+
- base: golang:1.20
96+
tag: go1.20
97+
- base: golang:1.21
98+
tag: go1.21
99+
- base: golang:1.22
100+
tag: go1.22
101+
# Python: only support lts versions
102+
- base: python:latest
103+
tag: python
104+
- base: python:3.12
105+
tag: python3.12
106+
- base: python:3.11
107+
tag: python3.11
108+
- base: python:3.10
109+
tag: python3.10
110+
- base: python:3.9
111+
tag: python3.9
112+
- base: python:3.8
113+
tag: python3.8
114+
- base: python:2.7
115+
tag: python2.7
116+
# Rust
117+
- base: rust:latest
118+
tag: rust
119+
# Erlang
120+
- base: erlang:latest
121+
tag: erlang
21122
steps:
22123
- name: Checkout
23124
uses: actions/checkout@v4
@@ -50,7 +151,8 @@ jobs:
50151
push: true
51152
build-args: |
52153
VERSION=${{ env.VERSION }}
154+
TAG=${{ matrix.tag }}
155+
BASEIMAGE=${{ matrix.base }}
53156
tags: |
54-
${{ env.docker_hub_tag }}:latest
55-
${{ env.docker_hub_tag }}:${{ env.VERSION }}
56-
${{ env.github_package_tag }}:${{ env.VERSION }}
157+
${{ env.docker_hub_tag }}:${{ matrix.tag }}
158+
${{ env.github_package_tag }}:${{ matrix.tag }}

docker/Dockerfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
FROM golang:latest AS builder
2-
3-
ARG TARGETARCH
41
ARG VERSION
2+
ARG TAG
3+
ARG BASEIMAGE
4+
5+
FROM golang:latest AS builder
56

67
COPY ./ /app
78
WORKDIR /app
8-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} \
9-
go build -ldflags "-s -w -X 'main.version=${VERSION}' " \
9+
RUN CGO_ENABLED=0 GOOS=linux \
10+
go build -ldflags "-s -w -X 'main.version=${VERSION}-${TAG}' " \
1011
-o /app/opensca-cli main.go
1112

12-
FROM scratch
13+
FROM ${BASEIMAGE}
1314
LABEL authors="OpenSCA Team <opensca@anpro-tech.com>"
1415

1516
COPY --from=builder /app/opensca-cli /app/opensca-cli
17+
COPY --from=builder /app/opensca-cli /app/config.json
1618
WORKDIR /src
17-
ENTRYPOINT [ "/app/opensca-cli"]
18-
CMD ["-path", "/src", "-config", "/src/config.json"]
19+
ENTRYPOINT [ "/app/opensca-cli", "-path", "/src"]
20+
CMD ["-config", "/src/config.json"]

0 commit comments

Comments
 (0)