Skip to content

Commit 05417f9

Browse files
author
Yaroslav Voitenko
committed
feat(dockerize-app): add docker image, small enhancements
1 parent 2518b72 commit 05417f9

File tree

7 files changed

+71
-5
lines changed

7 files changed

+71
-5
lines changed

.github/workflows/docker-image.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
name: Create and publish a Docker image with tags
3+
4+
# Configures this workflow to run every time a change is pushed and have tags
5+
on:
6+
push:
7+
tags:
8+
- '*'
9+
10+
# 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.
11+
env:
12+
REGISTRY: ghcr.io
13+
#IMAGE_NAME: ${{ github.repository }}
14+
IMAGE_NAME: justcoded/php-code-analysis
15+
16+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
17+
jobs:
18+
build-and-push-image:
19+
runs-on: ubuntu-latest
20+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
21+
permissions:
22+
contents: read
23+
packages: write
24+
#
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
# Uses the `docker/login-action` action to log in to the Container registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
29+
- name: Log in to the Container registry
30+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
36+
- name: Extract metadata (tags, labels) for Docker
37+
id: meta
38+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
# 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.
42+
# 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.
43+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
44+
- name: Build and push Docker image
45+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
46+
with:
47+
context: src/builds
48+
push: true
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,3 @@ Thumbs.db
1818

1919
# Mac DS_Store Files
2020
.DS_Store
21-
22-
# built binaries
23-
src/builds

src/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ WHP_SECURE=true
77
WHP_HOST=httpproxy.test
88
WHP_PORT=8082
99

10-
WHP_APP_KEY=whp_CyJUXvwTEVGxvDKg
10+
WHP_APP_KEY=
1111
WHP_SOCKET_TIMEOUT=60
1212
WHP_SOCKET_CHANNEL_BASENAME=App.Webhooks
1313
WHP_SOCKET_VERIFY_SSL=false

src/app/Commands/ProxyCommand.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public function handle(): void
4141
{
4242
$channelIdentifier = $this->option('channel') ?? $this->ask('Enter the channel UUID or webhook URL:');
4343

44+
if (empty($channelIdentifier)) {
45+
$this->error('The channel identifier is required');
46+
47+
return;
48+
}
49+
4450
try {
4551
$channelUuid = $this->webhookProxy->parseChannelUuid($channelIdentifier);
4652
} catch (InvalidArgumentException $e) {
@@ -50,6 +56,13 @@ public function handle(): void
5056
}
5157

5258
$forwardUrl = $this->option('forward-url') ?? $this->ask('Enter the URL to forward to:');
59+
60+
if (empty($forwardUrl)) {
61+
$this->error('The forward URL is required');
62+
63+
return;
64+
}
65+
5366
$webhookUrl = $this->webhookProxy->webhookUrl($channelUuid);
5467

5568
if ($forwardUrl === $this->webhookProxy->webhookUrl($channelUuid)) {

src/builds/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM php:8.3-cli
2+
3+
COPY whp /bin/
4+
RUN chmod +x /bin/whp
5+
6+
ENTRYPOINT ["/bin/whp"]

src/builds/whp

18.4 MB
Binary file not shown.

src/config/whp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
'host' => env('WHP_HOST', 'request-proxy.dev-net.co'),
66
'port' => env('WHP_PORT'),
77
'socket' => [
8-
'app_key' => env('WHP_APP_KEY', 'whp_CyJUXvwTEVGxvDKg'),
8+
'app_key' => env('WHP_APP_KEY'),
99
'timeout' => env('WHP_SOCKET_TIMEOUT', 20),
1010
'channel_basename' => env('WHP_SOCKET_CHANNEL_BASENAME', 'App.Webhooks'),
1111
'verify_ssl' => env('WHP_SOCKET_VERIFY_SSL', true),

0 commit comments

Comments
 (0)