-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
324 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.git | ||
node_modules | ||
dist | ||
scripts | ||
**/Dockerfile | ||
docker-compose* | ||
.dockerignore |
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,43 @@ | ||
FROM node:20-slim AS base | ||
|
||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
|
||
RUN corepack enable | ||
|
||
FROM base AS build | ||
|
||
COPY . /usr/src/app | ||
WORKDIR /usr/src/app | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile | ||
RUN pnpm build | ||
RUN pnpm deploy --filter=api --prod /prod/api | ||
RUN pnpm deploy --filter=web --prod /prod/web | ||
|
||
FROM base AS api | ||
|
||
WORKDIR /app | ||
COPY --from=build /prod/api /app | ||
EXPOSE 3000 | ||
CMD ["node", "dist/main.js"] | ||
|
||
FROM nginx:stable AS web | ||
|
||
# This tool converts env vars into json to be injected into the config | ||
ADD https://s3.amazonaws.com/se-com-docs/bins/json_env /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/json_env | ||
|
||
COPY apps/web/docker/nginx.conf /etc/nginx/conf.d/default.conf | ||
COPY apps/web/docker/expires.conf /etc/nginx/conf.d/expires.conf | ||
COPY apps/web/docker/entrypoint.sh /usr/local/bin/entrypoint.sh | ||
RUN chmod +x /usr/local/bin/entrypoint.sh | ||
|
||
ENV CONFIG_FILE_PATH=/app/config/app.json | ||
|
||
WORKDIR /app | ||
COPY --from=build /prod/web/dist /app | ||
RUN rm -rf /app/config/* | ||
|
||
ENTRYPOINT ["entrypoint.sh"] | ||
|
||
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 |
---|---|---|
@@ -1,3 +1,53 @@ | ||
# [Vue.js](https://vuejs.org/) + [NestJS](https://nestjs.com/) Monorepo | ||
|
||
[![CircleCI](https://circleci.com/gh/modernweb-pl/vue-nest-monorepo/tree/master.svg?style=svg)](https://circleci.com/gh/modernweb-pl/workflows/vue-nest-monorepo/tree/master) | ||
|
||
|
||
## Docker support | ||
|
||
Repository includes Docker support for building and pushing images to GitHub Packages. Follow the steps below to build and push the Docker images. | ||
|
||
### Prerequisites | ||
|
||
Ensure you have Docker installed and running on your machine. You will also need to [authenticate to the GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry) to push the Docker images. | ||
|
||
```bash | ||
echo $GITHUB_TOKEN | docker login ghcr.io -u <your-github-username> --password-stdin | ||
``` | ||
|
||
Adjust `docker.registry` and `homegae` fields in `package.json` which are used to properly name the images and link them to your GitHub repository in GitHub Packages: | ||
|
||
```json | ||
{ | ||
"homepage": "https://github.com/<your-github-username>/<your-repository-name>", | ||
"docker": { | ||
"registry": "ghcr.io/<your-github-username>/<your-repository-name>" | ||
} | ||
} | ||
``` | ||
|
||
### Building the Docker Images | ||
|
||
To build the Docker images locally, you can use the following command: | ||
|
||
```bash | ||
pnpm docker:build | ||
``` | ||
|
||
### Pushing the Docker Images to GitHub Packages | ||
|
||
Once the images are built, push them to GitHub Packages using the following command: | ||
|
||
```bash | ||
pnpm docker:push | ||
``` | ||
|
||
### Docker Compose Setup | ||
|
||
Repository also includes a `docker-compose.yml` file for easier multi-container setup and orchestration. Use Docker Compose to start the services locally by running: | ||
|
||
```bash | ||
docker-compose up | ||
``` | ||
|
||
This will spin up all defined services and link containers as needed. |
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
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
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 |
---|---|---|
@@ -1,23 +1,31 @@ | ||
version: '3.7' | ||
|
||
services: | ||
web: | ||
build: | ||
context: . | ||
dockerfile: apps/web/Dockerfile | ||
target: web | ||
environment: | ||
- API_URL=http://localhost:3000/api | ||
- CONFIG_VARS=API_URL | ||
- CONFIG_VARS=API_URL,DEMO_MODE | ||
- API_URL=http://localhost:3000 | ||
- DEMO_MODE=true | ||
ports: | ||
- 8080:80 | ||
- "8080:80" | ||
tty: true | ||
|
||
api: | ||
build: | ||
context: . | ||
dockerfile: apps/api/Dockerfile | ||
target: api | ||
environment: | ||
- AUTH_SECRET=ThisIsNotASecretKeyJustForTesting | ||
- MONGO_URL=mongodb://mongo/vue-nest-monorepo | ||
- NODE_ENV=demo | ||
ports: | ||
- 3000:3000 | ||
- "3000:3000" | ||
tty: true | ||
|
||
mongo: | ||
image: mongo:8 | ||
ports: | ||
- "27017:27017" | ||
volumes: | ||
- .data/mongo:/var/lib/mysql |
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
Oops, something went wrong.