-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move environment variables and defaults to backend * Remove pre-built certs * Move everything to a single node instance * Add dev environment * Updated README.md * Add package lock * Add build step files * Change to correct path * Move all data to a single directory * Correct Dockerfile paths * Ensure https only engages when files are present * Split more/less volatile files for faster builds * Fix permissions on node files
- Loading branch information
1 parent
d920319
commit 0be979a
Showing
17 changed files
with
13,653 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: "2" | ||
|
||
services: | ||
copilot-backend: | ||
build: | ||
context: backend | ||
dockerfile: Dockerfile | ||
volumes: | ||
- ./data/copilot-backend-data/logs:/opt/logs | ||
# Mount the copilot.db file to persist the database | ||
- ./data/data:/opt/copilot/backend/data | ||
|
||
copilot-frontend: | ||
build: | ||
context: frontend | ||
dockerfile: Dockerfile | ||
target: dev | ||
volumes: | ||
- ./frontend:/app | ||
environment: | ||
- SERVER_HOST=${SERVER_HOST:-localhost} # Set the domain name of your server | ||
ports: | ||
- "80:80" | ||
- "5173:5173" | ||
|
||
networks: | ||
default: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,58 @@ | ||
# Use a node.js base image | ||
FROM node:21 as builder | ||
|
||
# Set the working directory | ||
WORKDIR / | ||
# Drop root | ||
USER node | ||
|
||
# Copy project files into the working directory | ||
COPY . . | ||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy the package.json and package-lock.json files into the working directory | ||
COPY package.json package-lock.json ./ | ||
# Install project dependencies | ||
RUN npm install | ||
RUN npm ci | ||
|
||
# Copy project files into the working directory | ||
COPY --chown=node . . | ||
|
||
# Run the Vue.js project build | ||
RUN npm run build-only | ||
|
||
FROM node:21 as dev | ||
|
||
RUN apt-get update && apt-get install -y openssl | ||
|
||
RUN mkdir -p /certs & \ | ||
openssl req -x509 -subj "/CN=localhost" -nodes -newkey rsa:4096 -keyout /certs/key.pem -out /certs/cert.pem -days 365 && \ | ||
chown -R node:node /certs | ||
|
||
# Drop root | ||
USER node | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
CMD npm i && npm run start-vue | ||
|
||
FROM nginx:1.24.0-alpine | ||
|
||
# Copy custom Nginx configuration | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
# Added to create self-signed cert on run time if needed | ||
RUN apk add openssl | ||
|
||
# Copy built static files from the builder stage | ||
COPY --from=builder dist /usr/share/nginx/html | ||
# Set environment variables | ||
ENV SERVER_HOST=localhost | ||
ENV TLS_CERT_PATH=/etc/nginx/certs.d/server.crt | ||
ENV TLS_KEY_PATH=/etc/nginx/certs.d/server.key | ||
|
||
# Copy entrypoint | ||
COPY build/docker-entrypoint.d/90-copilot-ssl.sh /docker-entrypoint.d/90-copilot-ssl.sh | ||
RUN chmod +x /docker-entrypoint.d/90-copilot-ssl.sh | ||
|
||
EXPOSE 2000 | ||
# Setup template | ||
RUN mkdir /etc/nginx/templates | ||
COPY build/etc/nginx/sites-enabled/default.conf /etc/nginx/templates/default.conf.template | ||
|
||
# Copy built static files from the builder stage | ||
COPY --from=builder /app/dist /var/www/copilot | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
|
||
if [[ -z "${SERVER_HOST}" ]]; then | ||
echo "No SERVER_HOST set!" | ||
echo "Please set the SERVER_HOST environment variable to use CoPilot" | ||
exit 1; | ||
else | ||
echo "Host is now https://${SERVER_HOST}:${SERVER_PORT}" | ||
fi | ||
|
||
if [[ ! -f "${TLS_CERT_PATH}" || ! -f "${TLS_KEY_PATH}" ]]; then | ||
echo "No TLS certs found. Generating...." | ||
mkdir -p $(dirname "${TLS_CERT_PATH}") | ||
openssl req -x509 -subj "/CN=${SERVER_HOST}" -nodes -newkey rsa:4096 -keyout "${TLS_KEY_PATH}" -out "${TLS_CERT_PATH}" -days 365 | ||
else | ||
echo "TLS certificates found" | ||
fi | ||
|
||
if [[ ! -f /etc/nginx/certs/dhparams.pem ]]; then | ||
echo "Generating new DH parameters - this may take a while..." | ||
mkdir -p /etc/nginx/certs/ | ||
openssl dhparam -out /etc/nginx/certs/dhparams.pem 2048 | ||
else | ||
echo "... DH parameters found" | ||
fi |
Oops, something went wrong.