Skip to content

Commit a709126

Browse files
committed
Initial commit
0 parents  commit a709126

File tree

10 files changed

+923
-0
lines changed

10 files changed

+923
-0
lines changed

.DS_Store

6 KB
Binary file not shown.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
# 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.
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
13+
jobs:
14+
build-and-push-image:
15+
runs-on: ubuntu-latest
16+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
17+
permissions:
18+
contents: read
19+
packages: write
20+
attestations: write
21+
id-token: write
22+
#
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v5
26+
# 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.
27+
- name: Log in to the Container registry
28+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
29+
with:
30+
registry: ${{ env.REGISTRY }}
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
# 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.
34+
- name: Extract metadata (tags, labels) for Docker
35+
id: meta
36+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
37+
with:
38+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
39+
# 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.
40+
# 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.
41+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
42+
- name: Build and push Docker image
43+
id: push
44+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
45+
with:
46+
context: .
47+
push: true
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}
50+
build-args: |
51+
APP_VERSION=${{ github.event.release.tag_name }}
52+
53+
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
54+
- name: Generate artifact attestation
55+
uses: actions/attest-build-provenance@v3
56+
with:
57+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
58+
subject-digest: ${{ steps.push.outputs.digest }}
59+
push-to-registry: true

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# dev
2+
.yarn/
3+
!.yarn/releases
4+
.vscode/*
5+
!.vscode/launch.json
6+
!.vscode/*.code-snippets
7+
.idea/workspace.xml
8+
.idea/usage.statistics.xml
9+
.idea/shelf
10+
11+
# deps
12+
node_modules/
13+
14+
# env
15+
.env
16+
.env.production
17+
18+
# logs
19+
logs/
20+
*.log
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
pnpm-debug.log*
25+
lerna-debug.log*
26+
27+
# misc
28+
.DS_Store
29+
.idea/
30+
*.iml

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM node:24-alpine AS deps
2+
WORKDIR /app
3+
COPY package.json package-lock.json ./
4+
RUN npm ci
5+
6+
FROM node:24-alpine AS build
7+
WORKDIR /app
8+
COPY --from=deps /app/node_modules ./node_modules
9+
COPY tsconfig.json ./
10+
COPY src ./src
11+
RUN npm run build
12+
13+
FROM node:24-alpine AS runner
14+
WORKDIR /app
15+
ENV NODE_ENV=production
16+
COPY package.json package-lock.json ./
17+
RUN npm ci --omit=dev
18+
COPY --from=build /app/dist ./dist
19+
COPY config.yml ./config.yml
20+
EXPOSE 3000
21+
CMD ["node", "dist/index.js"]

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Deployman
2+
3+
Minimal Hono server for deploying a binary payload to a configured location.
4+
5+
## Requirements
6+
7+
- Node.js 20+
8+
9+
## Configure
10+
11+
Create `config.yml` in the project root:
12+
13+
```yml
14+
secret: foobar
15+
locations:
16+
token: location
17+
foobar: /srv/server/
18+
file: /srv/server/some_file.txt
19+
```
20+
21+
Behavior notes:
22+
- `locations` must include the provided `token`.
23+
- If the location path is a directory, the uploaded file is placed inside it.
24+
- If the location path is a file, the upload writes to that file.
25+
- If the location path does not exist, it is treated as a file path.
26+
27+
## Run locally
28+
29+
```bash
30+
npm install
31+
npm run dev
32+
```
33+
34+
## Deploy a file
35+
36+
```bash
37+
curl -X PUT \
38+
--data-binary @foobar.jar \
39+
"http://localhost:3000/deploy?secret=foobar&token=foobar&filename=foobar.jar"
40+
```
41+
42+
Responses:
43+
- `201` on success
44+
- `401` when `secret` or `token` is invalid
45+
- `400` when `filename` contains `/` or `\`
46+
47+
## Docker
48+
49+
Build and run:
50+
51+
```bash
52+
docker build -t deployman .
53+
docker run --rm -p 3000:3000 deployman
54+
```
55+
56+
To use a host config file:
57+
58+
```bash
59+
docker run --rm -p 3000:3000 -v "$PWD/config.yml:/app/config.yml" deployman
60+
```

config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
secret: foobar
2+
locations:
3+
token: location
4+
foobar: /tmp/
5+
file: /tmp/some_file.txt

0 commit comments

Comments
 (0)