Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 Add port forward pod that's rebuilt regularly #98

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-push-db-utils.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and push image
name: Build and push image [DB Utils]

on:
push:
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/build-push-pf-pod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and push image [Port Forward Pod]

on:
push:
workflow_dispatch:

env:
IMAGE_NAME: hmpps-delius-alfresco-port-forward-pod

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: ${{ env.IMAGE_NAME }}
- name: Build and push Docker image
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445
with:
context: ./tools/port-forward/
push: true
tags: ghcr.io/${{ github.repository_owner }}/${{ steps.meta.outputs.tags }}, ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Docker image
if: github.ref != 'refs/heads/main'
uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445
with:
context: ./tools/port-forward/
push: true
tags: ghcr.io/${{ github.repository_owner }}/${{ steps.meta.outputs.tags }}, ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ github.run_id }}
labels: ${{ steps.meta.outputs.labels }}
11 changes: 11 additions & 0 deletions tools/port-forward/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM alpine:3

RUN apk add --update --no-cache socat \
&& rm -rf /var/cache/apk/

RUN addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup

USER 1001

CMD ["sh", "-c", "socat tcp-listen:$LOCAL_PORT,reuseaddr,fork tcp:$REMOTE_HOST:$REMOTE_PORT & pid=$! && trap \"kill $pid\" SIGINT && echo \"Socat started listening on $LOCAL_PORT: Redirecting traffic to $REMOTE_HOST:$REMOTE_PORT ($pid)\" && wait $pid"]