Skip to content

Commit

Permalink
Merge Release 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sharunkumar committed Mar 31, 2024
2 parents 0fcb9f6 + da6fc9e commit 5fdad66
Show file tree
Hide file tree
Showing 19 changed files with 210 additions and 437 deletions.
6 changes: 0 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@
"jest": true,
},
},
{
"files": ["server.mjs"],
"env": {
"node": true,
},
},
{
"files": ["src/**"],
"globals": {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ jobs:

- name: Compress artifacts
run: |
zip -r Voyager-Web-${{ github.ref_name }}-Build.zip dist
zip -r Voyager-Web-${{ github.ref_name }}.zip dist
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: Voyager-Web-${{ github.ref_name }}-Build.zip
path: Voyager-Web-${{ github.ref_name }}-Build.zip
path: Voyager-Web-${{ github.ref_name }}.zip

build_ios:
runs-on: ubuntu-latest
Expand Down
20 changes: 5 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,16 @@ RUN pnpm build


# stage 2: runtime
FROM base AS runner
FROM docker.io/library/nginx AS runner

ARG UID=911 GID=911

COPY package.json pnpm-lock.yaml server.mjs ./
COPY patches ./patches

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile --ignore-scripts
COPY generate_config.sh /docker-entrypoint.d/generate_config.sh

# Create a dedicated user and group
RUN set -eux; \
addgroup -g "${GID}" voyager; \
adduser -u "${UID}" -D -G voyager voyager
COPY nginx.conf.template /etc/nginx/templates/default.conf.template

USER voyager
COPY --from=builder /voyager/dist /var/www

ENV NODE_ENV=production PORT=5314

COPY --from=builder /voyager/dist ./dist
ENV NGINX_PORT=5314

EXPOSE 5314/tcp

CMD ["node","./server.mjs"]
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,29 @@ Note: The provided Dockerfile creates a container which will eventually run Voya

#### Traditional Deployment

If you want to run a production build without Docker, you can build from source and run with the following commands (change `PORT` to whatever you prefer):
While Docker makes things easier, Voyager can be hosted by any HTTP server (nginx, apache etc).

```sh
# Build from source (Or, download web artifact from Github Releases)
pnpm install
pnpm build
NODE_ENV=production PORT=5106 node server.mjs

# Then, serve ./dist with your favorite HTTP server - nginx, apache etc
# (make sure 404 goes to index.html)
# Below is a simple example for dev/testing (not recommended for production):
npm install --global http-server
cp dist/index.html dist/404.html # magic file for http-server
http-server dist
```

Optionally, you can serve a custom list of instance(s) in the `/_config` endpoint, with JSON payload of following format:

```json
{ "customServers": ["lemmy.world", "lemm.ee"] }
```

For production, serve `index.html` with `Cache-Control: no-cache` and `/assets` with a long cache period (files in assets are immutable)

### Ecosystem

- 🇫🇮 [m.lemmy.world](https://m.lemmy.world) - Voyager hosted by the mastodon.world team. [Contact/privacy](https://mastodon.world/about)
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "app.vger.voyager"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 234
versionName "2.2.4"
versionCode 236
versionName "2.3.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
34 changes: 34 additions & 0 deletions generate_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# Function to sanitize input
sanitize_input() {
# Remove leading and trailing whitespaces
local sanitized_input
sanitized_input=$(echo "$1" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
echo "$sanitized_input"
}

# Get comma-separated list from the environment variable and sanitize it
servers=$(sanitize_input "$CUSTOM_LEMMY_SERVERS")

# Split comma-separated list into an array
IFS=',' read -ra server_array <<< "$servers"

# Convert array to JSON format
json="{ \"customServers\": ["

for server in "${server_array[@]}"; do
# Sanitize each server name
sanitized_server=$(sanitize_input "$server")
if [ -n "$sanitized_server" ]; then
json+="\"$sanitized_server\", "
fi
done

# Remove trailing comma and add closing bracket
json="${json%, } ] }"

# Write JSON to a file
echo "$json" > /var/www/config.json

echo "JSON file generated: config.json"
4 changes: 2 additions & 2 deletions ios/App/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.2.4</string>
<string>2.3.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>234</string>
<string>236</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
23 changes: 23 additions & 0 deletions nginx.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen ${NGINX_PORT};

gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;
gzip_comp_level 9;

root /var/www/;

location / {
try_files $uri /index.html;
add_header Cache-Control no-cache;
}

location /assets/ {
add_header Cache-Control max-age=31536000;
}

location /_config {
alias /var/www/config.json;
add_header Cache-Control no-cache;
}
}
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "voyager",
"description": "A progressive webapp Lemmy client",
"private": true,
"version": "2.2.4",
"version": "2.3.0",
"type": "module",
"packageManager": "pnpm@8.15.5+sha256.4b4efa12490e5055d59b9b9fc9438b7d581a6b7af3b5675eb5c5f447cee1a589",
"scripts": {
Expand All @@ -28,10 +28,7 @@
"@capacitor/browser@5.2.0": "patches/@capacitor__browser@5.2.0.patch"
}
},
"dependencies": {
"compression": "^1.7.4",
"express": "^4.19.1"
},
"dependencies": {},
"devDependencies": {
"@aeharding/remark-lemmy-spoiler": "^1.0.1",
"@babel/preset-react": "^7.23.3",
Expand Down
Loading

0 comments on commit 5fdad66

Please sign in to comment.