Added docker workflow
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/materialious"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -0,0 +1,35 @@
|
||||
name: Production Vite workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./materialious
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./materialious
|
||||
push: true
|
||||
tags: wardpearce/materialious:latest
|
||||
@@ -24,12 +24,10 @@
|
||||
- Dash support.
|
||||
- Chapters.
|
||||
- Audio only mode.
|
||||
- Playlists.
|
||||
- PWA support.
|
||||
|
||||
## Todo
|
||||
- Docker building & publishing workflow.
|
||||
- Launching 'materialio.us'.
|
||||
- Locking down git branches & setup PR requirements.
|
||||
- Localization.
|
||||
|
||||
## Previews
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# Specify the base image
|
||||
FROM node AS builder
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and package-lock.json to the working directory
|
||||
COPY package*.json ./
|
||||
|
||||
# Copy the rest of the project files to the working directory
|
||||
COPY . .
|
||||
|
||||
# Create placeholder env vars
|
||||
RUN echo "VITE_DEFAULT_INVIDIOUS_INSTANCE=VITE_DEFAULT_INVIDIOUS_INSTANCE_PLACEHOLDER" > .env && \
|
||||
echo "VITE_DEFAULT_FRONTEND_URL=VITE_DEFAULT_FRONTEND_URL_PLACEHOLDER" > .env && \
|
||||
echo "VITE_DEFAULT_SPONSERBLOCK_INSTANCE=VITE_DEFAULT_SPONSERBLOCK_INSTANCE_PLACEHOLDER" > .env && \
|
||||
echo "VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE=VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE_PLACEHOLDER" >> .env
|
||||
|
||||
# Install dependencies and build the project
|
||||
RUN npm install && npm run build
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
# Remove the default nginx configuration
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Copy the nginx.conf file to the container
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Copy the built Vite project from the builder stage
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# Expose the desired port
|
||||
EXPOSE 80
|
||||
|
||||
# Copy the replace_env_vars.sh script
|
||||
COPY replace_env_vars.sh /replace_env_vars.sh
|
||||
RUN chmod +x /replace_env_vars.sh
|
||||
|
||||
# Replace env vars & Start nginx
|
||||
CMD ["/bin/sh", "-c", "/replace_env_vars.sh && nginx -g \"daemon off;\""]
|
||||
@@ -0,0 +1,17 @@
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
default_type application/octet-stream;
|
||||
include /etc/nginx/mime.types;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
ROOT_DIR=./
|
||||
|
||||
# Replace env vars in JavaScript and HTML files served by NGINX
|
||||
find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VITE_DEFAULT_INVIDIOUS_INSTANCE_PLACEHOLDER|'"$VITE_DEFAULT_INVIDIOUS_INSTANCE"'|g' {} +
|
||||
find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE_PLACEHOLDER|'"$VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE"'|g' {} +
|
||||
find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VITE_DEFAULT_FRONTEND_URL_PLACEHOLDER|'"$VITE_DEFAULT_FRONTEND_URL"'|g' {} +
|
||||
find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VITE_DEFAULT_SPONSERBLOCK_INSTANCE_PLACEHOLDER|'"$VITE_DEFAULT_SPONSERBLOCK_INSTANCE"'|g' {} +
|
||||
Reference in New Issue
Block a user