Skip to content

Commit

Permalink
chore: cleaned up some docker stuff and improved dev workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ADRFranklin committed Mar 29, 2024
1 parent 52474e9 commit 60bfab4
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 55 deletions.
15 changes: 3 additions & 12 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
FROM qmcgaw/basedevcontainer:v0.24.0-alpine
FROM qmcgaw/nodedevcontainer
# Install Alpine packages
RUN apk add -q --update --progress --no-cache nodejs npm yarn curl
# Setup shells
RUN echo "plugins=(vscode git colorize npm npx yarn docker docker-compose)" >> /root/.zshrc-specific
# Sets directories for NPM global packages
ENV NODE_PATH="/root/.npm-packages/lib/node_modules" \
MANPATH="/root/.npm-packages/share/man"
RUN echo "prefix = /root/.npm-packages" >> /root/.npmrc
ENV PATH=/root/.npm-packages/bin:$PATH
# Install some global NPM packages
RUN yarn global add -g nodemon jest
RUN apk add -q --update --progress --no-cache curl
# Install Task
RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin && chmod +x /usr/local/bin/task
RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin && chmod +x /usr/local/bin/task
75 changes: 41 additions & 34 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,65 @@
{
"name": "project-dev",
"dockerComposeFile": ["docker-compose.yml"],
"name": "petio-dev",
"dockerComposeFile": [
"docker-compose.yml"
],
"service": "vscode",
"runServices": ["vscode", "mongo"],
"runServices": [
"vscode",
"mongo"
],
"shutdownAction": "stopCompose",
"postCreateCommand": "~/.ssh.sh",
"postCreateCommand": "~/.windows.sh && yarn install",
"workspaceFolder": "/workspace",
"initializeCommand": "echo 'Hello World!'",
// "overrideCommand": "",
"forwardPorts": [],
"customizations": {
"vscode": {
"extensions": [
"esbenp.prettier-vscode",
"mohsen1.prettify-json",
"dbaeumer.vscode-eslint",
"ms-vscode.vscode-typescript-tslint-plugin",
"esbenp.prettier-vscode",
"visualstudioexptteam.vscodeintellicode",
"christian-kohler.npm-intellisense",
"eg2.vscode-npm-script",
"eamodio.gitlens", // IDE Git information
"eamodio.gitlens",
"davidanson.vscode-markdownlint",
"ms-azuretools.vscode-docker", // Docker integration and linting
"shardulm94.trailing-spaces", // Show trailing spaces
"Gruntfuggly.todo-tree", // Highlights TODO comments
"bierner.emojisense", // Emoji sense for markdown
"stkb.rewrap", // rewrap comments after n characters on one line
"vscode-icons-team.vscode-icons", // Better file extension icons
"github.vscode-pull-request-github", // Github interaction
"redhat.vscode-yaml", // Kubernetes, Drone syntax highlighting
"bajdzis.vscode-database", // Supports connections to mysql or postgres, over SSL, socked
"IBM.output-colorizer", // Colorize your output/test logs
"ms-azuretools.vscode-docker",
"shardulm94.trailing-spaces",
"Gruntfuggly.todo-tree",
"bierner.emojisense",
"stkb.rewrap",
"vscode-icons-team.vscode-icons",
"github.vscode-pull-request-github",
"redhat.vscode-yaml",
"bajdzis.vscode-database",
"IBM.output-colorizer",
"github.copilot",
"usernamehw.errorlens",
"EditorConfig.EditorConfig"
"EditorConfig.EditorConfig",
"pmneo.tsimporter",
"DSKWRK.vscode-generate-getter-setter",
"yoavbls.pretty-ts-errors",
"BitBelt.converttoasciiart",
"typespec.typespec-vscode",
"rangav.vscode-thunder-client"
],
"settings": {
"files.eol": "\n",
"remote.extensionKind": {
"ms-azuretools.vscode-docker": "workspace"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.workingDirectories": ["/workspace/pkg/api"],
"eslint.validate": ["javascript", "typescript"],
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": false
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": false
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},
"prettier-eslint.eslintIntegration": true
"eslint.workingDirectories": [
"/workspace/pkg/api"
],
"eslint.validate": [
"javascript",
"typescript"
],
"prettier-eslint.eslintIntegration": true,
"dev.containers.copyGitConfig": true
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ services:
- ~/.zsh_history:/root/.zsh_history:z
# Git config
- ~/.gitconfig:/root/.gitconfig:z
# SSH Agent
- ${SSH_AUTH_SOCK:-/dev/null}:/ssh-agent
environment:
- TZ=Europe\London
- DB_URL=mongodb://mongo:27017/petio
- SSH_AUTH_SOCK=/ssh-agent
entrypoint: ['zsh', '-c', 'while sleep 1000; do :; done']

mongo:
Expand Down
6 changes: 0 additions & 6 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ tasks:
deps: ['build:pre']
cmds:
- task: build:fe
- task: build:adm
- task: build:api:prod

build:pre:
Expand All @@ -61,11 +60,6 @@ tasks:
cmds:
- yarn workspace frontend run build

build:adm:
dir: pkg/admin
cmds:
- yarn workspace admin run build

build:api:
dir: pkg/api
cmds:
Expand Down
3 changes: 1 addition & 2 deletions pkg/api/src/api/middleware/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export default () => {
const whitelist = httpConfig.corsDomains;
if (envConfig.isDevelopment) {
// add local react dev
whitelist.push('http://localhost:3001'); // frontend
whitelist.push('http://localhost:3002'); // admin
whitelist.push('http://localhost:3000'); // frontend
}

const corsOptions = {
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/src/helpers/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cookies from 'js-cookie';

const isDev = process.env.NODE_ENV === 'development';
const origin = isDev
? 'http://localhost:7777'
? process.env.REACT_APP_API_URL ?? 'http://localhost:7777'
: typeof window === 'undefined'
? ''
: `${window.location.protocol}//${window.location.host}`;
Expand Down

0 comments on commit 60bfab4

Please sign in to comment.