Skip to content

Commit dc2449a

Browse files
Adds support for publishing Docker image. Closes #12 (#1044)
1 parent 3e43c0f commit dc2449a

File tree

3 files changed

+169
-2
lines changed

3 files changed

+169
-2
lines changed

.github/workflows/create-release.yml

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
name: Create GitHub release
1+
name: Release
22
on:
33
push:
44
tags: ['v*']
55

6+
env:
7+
REGISTRY: ghcr.io
8+
IMAGE_NAME: ${{ github.repository }}
9+
IMAGE_DESCRIPTION: Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path.
10+
611
jobs:
712
publish_binaries:
813
name: Publish binaries
@@ -145,4 +150,78 @@ jobs:
145150
with:
146151
args: |
147152
output/binaries-*/*.zip
148-
output/installer-*/*.exe
153+
output/installer-*/*.exe
154+
deploy_docker:
155+
name: Publish Docker image
156+
runs-on: ubuntu-latest
157+
needs: [create_release]
158+
permissions:
159+
contents: read
160+
packages: write
161+
attestations: write
162+
id-token: write
163+
steps:
164+
- name: Checkout repository
165+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
166+
# Required for multi-platform images
167+
- name: Set up QEMU
168+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
169+
# Required for multi-platform images
170+
- name: Set up Docker Buildx
171+
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
172+
with:
173+
driver-opts: image=moby/buildkit:latest
174+
- name: Log in to the Container registry
175+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
176+
with:
177+
registry: ${{ env.REGISTRY }}
178+
username: ${{ github.actor }}
179+
password: ${{ secrets.GITHUB_TOKEN }}
180+
- name: Extract metadata (tags, labels) for Docker
181+
id: meta
182+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
183+
with:
184+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
185+
flavor: |
186+
latest=false
187+
tags: |
188+
type=semver,pattern={{version}}
189+
type=raw,value=latest,enable=${{ !contains(github.ref_name, '-beta') }}
190+
type=raw,value=beta,enable=${{ contains(github.ref_name, '-beta') }}
191+
labels: |
192+
org.opencontainers.image.description=${{ env.IMAGE_DESCRIPTION }}
193+
annotations: |
194+
org.opencontainers.image.description=${{ env.IMAGE_DESCRIPTION }}
195+
- name: Build and push Docker image
196+
if: "!contains(github.ref_name, '-beta')"
197+
id: push
198+
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
199+
with:
200+
context: .
201+
push: true
202+
tags: ${{ steps.meta.outputs.tags }}
203+
labels: ${{ steps.meta.outputs.labels }}
204+
annotations: ${{ steps.meta.outputs.annotations }}
205+
platforms: linux/amd64,linux/arm64
206+
build-args: |
207+
DEVPROXY_VERSION=${{ steps.meta.outputs.version }}
208+
- name: Build and push beta Docker image
209+
if: contains(github.ref_name, '-beta')
210+
id: push_beta
211+
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
212+
with:
213+
context: .
214+
file: ./Dockerfile_beta
215+
push: true
216+
tags: ${{ steps.meta.outputs.tags }}
217+
labels: ${{ steps.meta.outputs.labels }}
218+
annotations: ${{ steps.meta.outputs.annotations }}
219+
platforms: linux/amd64,linux/arm64
220+
build-args: |
221+
DEVPROXY_VERSION=${{ steps.meta.outputs.version }}
222+
- name: Generate artifact attestation
223+
uses: actions/attest-build-provenance@v2
224+
with:
225+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
226+
subject-digest: ${{ steps.push.outputs.digest || steps.push_beta.outputs.digest }}
227+
push-to-registry: true

Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM ubuntu:24.04
2+
3+
ARG DEVPROXY_VERSION=0.25.0
4+
ARG USERNAME=devproxy
5+
ENV DEVPROXY_VERSION=${DEVPROXY_VERSION}
6+
7+
EXPOSE 8000 8897
8+
9+
LABEL name="dev-proxy/dev-proxy:${DEVPROXY_VERSION}" \
10+
description="Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path." \
11+
homepage="https://aka.ms/devproxy" \
12+
maintainers="Waldek Mastykarz <[email protected]>, \
13+
Garry Trinder <[email protected]>" \
14+
org.opencontainers.image.source=https://github.com/dotnet/dev-proxy \
15+
org.opencontainers.image.description="Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path." \
16+
org.opencontainers.image.licenses=MIT
17+
18+
WORKDIR /app
19+
20+
RUN apt -y update && apt -y upgrade && \
21+
apt install -y \
22+
curl unzip && \
23+
apt -y clean && \
24+
rm -rf /var/lib/apt/lists/* && \
25+
# Create a new user
26+
useradd -ms /bin/bash ${USERNAME} && \
27+
# Install Dev Proxy
28+
/bin/bash -c "$(curl -sL https://aka.ms/devproxy/setup.sh)" -- v${DEVPROXY_VERSION} && \
29+
echo "export PATH=$PATH:$(pwd)/devproxy" >> /home/${USERNAME}/.bashrc && \
30+
# Create a directory for the configuration
31+
mkdir -p /home/${USERNAME}/.config && \
32+
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.config
33+
34+
# Prevents error "Couldn't find a valid ICU package" when running Dev Proxy
35+
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 \
36+
# Required for .NET to properly resolve SpecialFolder.ApplicationData
37+
XDG_DATA_HOME=/home/${USERNAME}/.config
38+
39+
VOLUME /config
40+
WORKDIR /config
41+
42+
USER ${USERNAME}
43+
44+
ENTRYPOINT ["/app/devproxy/devproxy", "--ip-address", "0.0.0.0"]

Dockerfile_beta

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM ubuntu:24.04
2+
3+
ARG DEVPROXY_VERSION=0.25.0
4+
ARG USERNAME=devproxy
5+
ENV DEVPROXY_VERSION=${DEVPROXY_VERSION}
6+
7+
EXPOSE 8000 8897
8+
9+
LABEL name="dev-proxy/dev-proxy:${DEVPROXY_VERSION}" \
10+
description="Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path." \
11+
homepage="https://aka.ms/devproxy" \
12+
maintainers="Waldek Mastykarz <[email protected]>, \
13+
Garry Trinder <[email protected]>" \
14+
org.opencontainers.image.source=https://github.com/dotnet/dev-proxy \
15+
org.opencontainers.image.description="Dev Proxy is an API simulator that helps you effortlessly test your app beyond the happy path." \
16+
org.opencontainers.image.licenses=MIT
17+
18+
WORKDIR /app
19+
20+
RUN apt -y update && apt -y upgrade && \
21+
apt install -y \
22+
curl unzip && \
23+
apt -y clean && \
24+
rm -rf /var/lib/apt/lists/* && \
25+
# Create a new user
26+
useradd -ms /bin/bash ${USERNAME} && \
27+
# Install Dev Proxy
28+
/bin/bash -c "$(curl -sL https://aka.ms/devproxy/setup-beta.sh)" -- v${DEVPROXY_VERSION} && \
29+
echo "export PATH=$PATH:$(pwd)/devproxy-beta" >> /home/${USERNAME}/.bashrc && \
30+
# Create a directory for the configuration
31+
mkdir -p /home/${USERNAME}/.config && \
32+
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.config
33+
34+
# Prevents error "Couldn't find a valid ICU package" when running Dev Proxy
35+
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 \
36+
# Required for .NET to properly resolve SpecialFolder.ApplicationData
37+
XDG_DATA_HOME=/home/${USERNAME}/.config
38+
39+
VOLUME /config
40+
WORKDIR /config
41+
42+
USER ${USERNAME}
43+
44+
ENTRYPOINT ["/app/devproxy-beta/devproxy-beta", "--ip-address", "0.0.0.0"]

0 commit comments

Comments
 (0)