-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
branches: | ||
- 'master' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: "VERSION=${GITHUB_REF##*/}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Step 1: Use the official Golang image as the build environment. | ||
# This image includes all the tools needed to compile Go applications. | ||
FROM golang:1.21 as builder | ||
|
||
# Version will be passed as a part of the build. | ||
ARG VERSION=dev | ||
|
||
# Set the Current Working Directory inside the container. | ||
WORKDIR /app | ||
|
||
# Copy the local package files to the container's workspace. | ||
COPY . . | ||
|
||
# Build the Go app for a Linux system. The -o flag specifies the output binary | ||
# name. | ||
RUN VERSION=${VERSION} make build | ||
|
||
# Step 2: Use a Docker multi-stage build to create a lean production image. | ||
# Start from a scratch (empty) image to keep the image size small. | ||
FROM scratch | ||
|
||
# Copy the binary from the builder stage to the production image. | ||
COPY --from=builder /app/udptlspipe / | ||
|
||
# Exact protocol depends on operation mode: tcp for server and udp for client. | ||
EXPOSE 8443/tcp | ||
EXPOSE 8443/udp | ||
|
||
ENTRYPOINT ["/udptlspipe", "-h"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters