Skip to content

Commit 3cb60fb

Browse files
Initial commit
0 parents  commit 3cb60fb

24 files changed

Lines changed: 1520 additions & 0 deletions

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
.git
4+
.DS_Store
5+
npm-debug.log
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build and Push Docker Image
2+
run-name: Build and push learn_mobile-preview image for ${{ github.ref_name }} by @${{ github.actor }}
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- develop
9+
tags:
10+
- "v*"
11+
pull_request:
12+
branches:
13+
- main
14+
15+
env:
16+
REGISTRY: ghcr.io
17+
IMAGE_NAME: ${{ github.repository }}
18+
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
jobs:
24+
build-and-push:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Log in to Container Registry
34+
if: github.event_name != 'pull_request'
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ${{ env.REGISTRY }}
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Extract metadata
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46+
tags: |
47+
type=ref,event=branch
48+
type=ref,event=pr
49+
type=semver,pattern={{version}}
50+
type=semver,pattern={{major}}.{{minor}}
51+
type=semver,pattern={{major}}
52+
type=raw,value=latest,enable={{is_default_branch}}
53+
54+
- name: Build and push Docker image
55+
uses: docker/build-push-action@v5
56+
with:
57+
context: .
58+
platforms: linux/amd64,linux/arm64
59+
push: ${{ github.event_name != 'pull_request' }}
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}
62+
cache-from: type=gha
63+
cache-to: type=gha,mode=max

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 build
2+
3+
WORKDIR /app
4+
5+
COPY package*.json ./
6+
RUN npm ci
7+
8+
COPY . .
9+
RUN npm run build
10+
11+
FROM nginx:1.29-alpine
12+
13+
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
14+
COPY docker/entrypoint.sh /docker-entrypoint-learn-mobile-preview.sh
15+
COPY --from=build /app/dist /usr/share/nginx/html
16+
17+
RUN chmod +x /docker-entrypoint-learn-mobile-preview.sh
18+
19+
EXPOSE 80
20+
21+
ENTRYPOINT ["/docker-entrypoint-learn-mobile-preview.sh"]

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Mobile Preview
2+
3+
A lightweight phone UI wrapper around an Expo web preview.
4+
5+
The app does not emulate native APIs. Expo handles the runtime; this project only displays the Expo web output inside a phone-shaped frame.
6+
7+
## Local Development
8+
9+
Start your Expo web app on port `3000`, then run:
10+
11+
```bash
12+
npm install
13+
npm run dev
14+
```
15+
16+
Open the wrapper at `http://localhost:5173`. It defaults to loading `http://localhost:3000`.
17+
18+
## Docker
19+
20+
Build the image:
21+
22+
```bash
23+
docker build -t learn_mobile-preview .
24+
```
25+
26+
Run it:
27+
28+
```bash
29+
docker run --rm -p 8080:80 learn_mobile-preview
30+
```
31+
32+
Open `http://localhost:8080`. The phone iframe will point at `http://localhost:3000` by default.
33+
34+
To target a different Expo web URL:
35+
36+
```bash
37+
docker run --rm -p 8080:80 -e PREVIEW_URL="http://localhost:3000" learn_mobile-preview
38+
```
39+
40+
## Container Registry
41+
42+
GitHub Actions publishes the image to GitHub Container Registry on pushes to `main`, `develop`, and `v*` tags:
43+
44+
```bash
45+
ghcr.io/<owner>/<repo>
46+
```
47+
48+
Pull requests build the image without pushing it. If the package appears private in GHCR, change the package visibility to public in the repository's package settings.

dist/assets/index-CsjKjlQs.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assets/index-DOD3Vl8z.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
window.__MOBILE_PREVIEW_CONFIG__ = {
2+
previewUrl: "http://localhost:3000",
3+
};

dist/config.template.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
window.__MOBILE_PREVIEW_CONFIG__ = {
2+
previewUrl: "${PREVIEW_URL}",
3+
};

dist/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Mobile Preview</title>
7+
<script src="/config.js"></script>
8+
<script type="module" crossorigin src="/assets/index-DOD3Vl8z.js"></script>
9+
<link rel="stylesheet" crossorigin href="/assets/index-CsjKjlQs.css">
10+
</head>
11+
<body>
12+
<div id="root"></div>
13+
</body>
14+
</html>

docker/entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
: "${PREVIEW_URL:=http://localhost:3000}"
5+
6+
envsubst '${PREVIEW_URL}' \
7+
< /usr/share/nginx/html/config.template.js \
8+
> /usr/share/nginx/html/config.js
9+
10+
exec nginx -g 'daemon off;'

0 commit comments

Comments
 (0)