Skip to content

Commit 1410afd

Browse files
authored
Merge pull request #26 from domesticchores/docker
updated and containerized
2 parents cbfc96d + d879a70 commit 1410afd

File tree

7 files changed

+4048
-42
lines changed

7 files changed

+4048
-42
lines changed

.dockerignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/go/build-context-dockerignore/
6+
7+
**/.classpath
8+
**/.dockerignore
9+
**/.env
10+
**/.gitignore
11+
**/.project
12+
**/.settings
13+
**/.toolstarget
14+
**/.vs
15+
**/.vscode
16+
**/.next
17+
**/.cache
18+
**/*.*proj.user
19+
**/*.dbmdl
20+
**/*.jfm
21+
**/charts
22+
**/docker-compose*
23+
**/compose.y*ml
24+
**/Dockerfile*
25+
**/node_modules
26+
**/npm-debug.log
27+
**/obj
28+
**/secrets.dev.yaml
29+
**/values.dev.yaml
30+
**/build
31+
**/dist
32+
README.md

Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# Comments are provided throughout this file to help you get started.
4+
# If you need more help, visit the Dockerfile reference guide at
5+
# https://docs.docker.com/go/dockerfile-reference/
6+
7+
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
8+
9+
ARG NODE_VERSION=20.19.4
10+
11+
FROM node:${NODE_VERSION}-alpine
12+
13+
# Use production node environment by default.
14+
ENV NODE_ENV production
15+
16+
17+
WORKDIR /usr/src/app
18+
19+
# Download dependencies as a separate step to take advantage of Docker's caching.
20+
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
21+
# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into
22+
# into this layer.
23+
RUN --mount=type=bind,source=package.json,target=package.json \
24+
--mount=type=bind,source=package-lock.json,target=package-lock.json \
25+
--mount=type=cache,target=/root/.npm \
26+
npm ci --omit=dev
27+
28+
# Run the application as a non-root user.
29+
USER node
30+
31+
# Copy the rest of the source files into the image.
32+
COPY . .
33+
34+
# Load default port if not specified in build command
35+
ARG PORT=8080
36+
ENV PORT=${PORT}
37+
38+
# Expose the port that the application listens on.
39+
EXPOSE ${PORT}
40+
41+
# Run the application.
42+
CMD node server.js

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,33 @@ Implement as:
1818
## Contributing
1919
### Pull Requests
2020
To contribute to themeswitcher, please fork this repository and submit a pull request. If it is a significant change (more than a couple lines) please create a new branch. Excluding ReadMe changes, pull requests to site will not be accepted.
21+
22+
### Environment Variables
23+
Create a `.env` file in the root directory using the following template. Contact an RTP to get the necessary secrets.
24+
```
25+
CLIENT_ID=themeswitcher
26+
CLIENT_SECRET=
27+
DEFAULT_CSS=csh-bootstrap-bootstrap
28+
EXPRESS_SESSION_SECRET=
29+
PORT=8080
30+
HOST=http://localhost:8080
31+
DB_URI=mongodb://themes:2cvtwcdye837nscp38@mongodb-theme:27017/themes?authSource=admin
32+
```
33+
For local development, the `DB_URI` is already populated with the URI to use the mongo image created in the docker compose. If you know what you're doing you can host and use your own DB, but why would you do that when there's one right here?
34+
### Viewing Local Database
35+
If you're developing locally, viewing the database contents for debugging can be achieved using the following commands:
36+
1. Authenticate into the database
37+
```bash
38+
docker exec -it mongodb-theme mongosh -u themes -p <yourpasswordhere> --authenticationDatabase admin
39+
```
40+
2. Select the `themes` table
41+
```bash
42+
use themes
43+
```
44+
3. view the `members` collection and return JSON data
45+
```bash
46+
db.members.find().pretty()
47+
```
2148
### Issues
2249
As themeswitcher is hosted on GitHub, it uses GitHub's issue tracker to document issues. Please open any issues there.
2350
### Adding Themes

docker-compose.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
services:
2+
themeswitcher:
3+
build: .
4+
container_name: themeswitcher
5+
depends_on:
6+
- mongodb
7+
environment:
8+
HOST: "${HOST}"
9+
DB_URI: "${DB_URI}"
10+
CLIENT_ID: "${CLIENT_ID}"
11+
CLIENT_SECRET: "${CLIENT_SECRET}"
12+
DEFAULT_CSS: "${DEFAULT_CSS}"
13+
EXPRESS_SESSION_SECRET: "${EXPRESS_SESSION_SECRET}"
14+
PORT: "${PORT}"
15+
ports:
16+
- "${PORT}:${PORT}"
17+
18+
mongodb:
19+
image: mongo:8.0-rc-noble
20+
container_name: mongodb-theme
21+
command: "mongod --bind_ip 0.0.0.0"
22+
environment:
23+
- "MONGO_INITDB_DATABASE=themes"
24+
- "MONGO_INITDB_ROOT_USERNAME=themes"
25+
- "MONGO_INITDB_ROOT_PASSWORD=2cvtwcdye837nscp38"
26+
ports:
27+
- "27017:27017"
28+
volumes:
29+
- type: volume
30+
source: mongodb
31+
target: /data/db/
32+
33+
volumes:
34+
mongodb:

0 commit comments

Comments
 (0)