Skip to content

Commit ff21085

Browse files
committed
perf: add Dockerfile
1 parent 6e66684 commit ff21085

4 files changed

Lines changed: 130 additions & 0 deletions

File tree

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
vendor
2+
build/*
3+
logs/*
4+
data/*
5+
release/*
6+
node_modules/
7+
Dockerfile

.github/workflows/build-image.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#
2+
name: Create and publish a Docker image
3+
4+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Tag to build'
10+
required: true
11+
default: 'latest'
12+
type: string
13+
14+
15+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
16+
env:
17+
REGISTRY: ghcr.io
18+
IMAGE_NAME: ${{ github.repository }}
19+
20+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
21+
jobs:
22+
build-and-push-image:
23+
runs-on: ubuntu-latest
24+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
25+
permissions:
26+
contents: read
27+
packages: write
28+
attestations: write
29+
id-token: write
30+
#
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
35+
- name: Log in to the Container registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
- name: Set up QEMU
42+
uses: docker/setup-qemu-action@v3
43+
- name: Set up Docker Buildx
44+
uses: docker/setup-buildx-action@v3
45+
- name: Extract metadata (tags, labels) for Docker
46+
id: meta
47+
uses: docker/metadata-action@v5
48+
with:
49+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
50+
tags: |
51+
type=raw, value=${{ inputs.tag }}
52+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
53+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
54+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
55+
- name: Build and push Docker image
56+
id: push
57+
uses: docker/build-push-action@v6
58+
with:
59+
platforms: linux/amd64,linux/arm64
60+
context: .
61+
push: true
62+
tags: ${{ steps.meta.outputs.tags }}
63+

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM golang:1.24-bullseye AS stage-build
2+
ARG TARGETARCH
3+
ENV CGO_ENABLED=0
4+
ENV GO111MODULE=on
5+
6+
WORKDIR /opt/wisp
7+
8+
COPY go.mod go.sum ./
9+
10+
RUN go mod download -x
11+
12+
COPY . .
13+
14+
RUN make build
15+
16+
FROM debian:bullseye-slim
17+
18+
ARG TARGETARCH
19+
ENV LANG=en_US.UTF-8
20+
ARG APT_MIRROR=http://deb.debian.org
21+
ARG DEPENDENCIES=" \
22+
bash-completion \
23+
jq \
24+
less \
25+
ca-certificates"
26+
27+
RUN set -ex \
28+
&& sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \
29+
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
30+
&& apt-get update \
31+
&& apt-get install -y --no-install-recommends ${DEPENDENCIES} \
32+
&& apt-get clean all \
33+
&& rm -rf /var/lib/apt/lists/*
34+
35+
WORKDIR /opt/wisp
36+
37+
COPY --from=stage-build /opt/wisp/build/wisp .
38+
39+
CMD ["./wisp"]

docker-compose.yaml.example

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: "3.0"
2+
3+
networks:
4+
wisp:
5+
driver: bridge
6+
7+
services:
8+
wisp:
9+
image: ghcr.io/jumpserver/wisp:latest
10+
container_name: jms_wisp
11+
ports:
12+
- "9090:9090"
13+
environment:
14+
LOG_LEVEL: DEBUG
15+
CORE_HOST: http://docker.host.internal:8080
16+
BOOTSTRAP_TOKEN: PleaseChangeMe
17+
networks:
18+
- guacd
19+
restart: always
20+
volumes:
21+
- ./data/:/opt/wisp/data/:rw # /opt/wisp/-> 本地项目路径, 修改 ./data 目录权限为777

0 commit comments

Comments
 (0)