Skip to content

Commit d92e883

Browse files
authored
initial commit
0 parents  commit d92e883

35 files changed

+18960
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Update the VARIANT arg in docker-compose.yml to pick a Node version: 10, 12, 14
2+
ARG VARIANT=16
3+
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
4+
5+
# See https://github.com/microsoft/vscode-dev-containers/tree/master/containers/docker-from-docker for more documentation
6+
# On how to use docker from within docker
7+
8+
# Install Docker CE CLI
9+
RUN apt-get update \
10+
&& apt-get install -y apt-transport-https ca-certificates curl gnupg2 lsb-release \
11+
&& curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null \
12+
&& echo "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list \
13+
&& apt-get update \
14+
&& apt-get install -y docker-ce-cli
15+
16+
# Install Docker Compose
17+
RUN LATEST_COMPOSE_VERSION=$(curl -sSL "https://api.github.com/repos/docker/compose/releases/latest" | grep -o -P '(?<="tag_name": ").+(?=")') \
18+
&& curl -sSL "https://github.com/docker/compose/releases/download/${LATEST_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \
19+
&& chmod +x /usr/local/bin/docker-compose
20+
21+
# Update args in docker-compose.yaml to set the UID/GID of the "node" user.
22+
ARG USER_UID=1000
23+
ARG USER_GID=$USER_UID
24+
RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then groupmod --gid $USER_GID node && usermod --uid $USER_UID --gid $USER_GID node; fi
25+
26+
# Add the node user to the docker group to access
27+
# the daemon without sudo
28+
RUN groupadd docker
29+
RUN usermod -a -G docker node

.devcontainer/devcontainer.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "next-image-s3-imgproxy-loader",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "application",
5+
"workspaceFolder": "/workspace",
6+
"settings": {
7+
"terminal.integrated.defaultProfile.linux": "bash"
8+
},
9+
"remoteEnv": {
10+
"PATH": "${containerEnv:PATH}:/workspace/bin"
11+
},
12+
"extensions": [
13+
"dbaeumer.vscode-eslint",
14+
"esbenp.prettier-vscode",
15+
"mikestead.dotenv",
16+
"ms-azuretools.vscode-docker",
17+
"ms-vsliveshare.vsliveshare",
18+
"wayou.vscode-todo-highlight",
19+
"xshrim.txt-syntax"
20+
],
21+
"forwardPorts": [
22+
3000,
23+
4000,
24+
9000,
25+
9001
26+
],
27+
"postCreateCommand": "bash -i .devcontainer/init.sh",
28+
"remoteUser": "node",
29+
"portsAttributes": {
30+
"3000":{
31+
"label": "Example Application",
32+
"onAutoForward": "notify"
33+
},
34+
"4000": {
35+
"label": "Imgproxy Server"
36+
},
37+
"9000": {
38+
"label": "Minio Server"
39+
},
40+
"9001": {
41+
"label": "Minio Console"
42+
}
43+
}
44+
}

.devcontainer/docker-compose.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
version: '3.7'
2+
3+
networks:
4+
next-image-s3-imgproxy-loader-network:
5+
name: next-image-s3-imgproxy-loader-network
6+
driver: bridge
7+
8+
volumes:
9+
next-image-s3-imgproxy-loader-mariadb-10.5.9__data:
10+
driver: local
11+
next-image-s3-imgproxy-loader-mariadb-10.5.9__config:
12+
driver: local
13+
next-image-s3-imgproxy-loader-minio-latest__data:
14+
driver: local
15+
16+
services:
17+
application:
18+
container_name: next-image-s3-imgproxy-loader
19+
build:
20+
context: .
21+
dockerfile: Dockerfile
22+
args:
23+
VARIANT: 14
24+
USER_UID: 1000
25+
USER_GID: 1000
26+
networks:
27+
- next-image-s3-imgproxy-loader-network
28+
volumes:
29+
- ..:/workspace:cached
30+
- ~/.ssh:/home/node/.ssh:ro
31+
- /var/run/docker.sock:/var/run/docker.sock
32+
command: sleep infinity
33+
user: node
34+
env_file:
35+
- ./workspace.env
36+
ports:
37+
- 4000:4000
38+
- 9000:9000
39+
- 9001:9001
40+
41+
# Minio
42+
next-image-s3-imgproxy-loader-minio-latest:
43+
container_name: next-image-s3-imgproxy-loader-minio-latest
44+
image: minio/minio:latest
45+
network_mode: service:application
46+
volumes:
47+
- type: volume
48+
source: next-image-s3-imgproxy-loader-minio-latest__data
49+
target: /data
50+
volume:
51+
nocopy: false
52+
command: server /data --console-address :9001
53+
env_file:
54+
- ./minio.env
55+
56+
# Imgproxy
57+
next-image-s3-imgproxy-loader-imgproxy-latest:
58+
container_name: next-image-s3-imgproxy-loader-imgproxy-latest
59+
image: darthsim/imgproxy:latest
60+
network_mode: service:application
61+
env_file:
62+
- ./imgproxy.env

.devcontainer/imgproxy.env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
IMGPROXY_BIND=0.0.0.0:4000
2+
IMGPROXY_ALLOWED_SOURCES=s3://
3+
IMGPROXY_USE_S3=true
4+
IMGPROXY_S3_ENDPOINT=http://localhost:9000
5+
IMGPROXY_KEY=91bdcda48ce22cd7d8d3a0eda930b3db1762bc1cba5dc13542e723b68fe55d6f9d18199cbe35191a45faf22593405cad0fe76ffec67d24f8aee861ac8fe44d96
6+
IMGPROXY_SALT=72456c286761260f320391fe500fcec53755958dabd288867a6db072e1bc1dbd84b15079838a83a715edc1ecad50c3ce91dd8fdef6f981816fa274f91d8ecf06
7+
AWS_ACCESS_KEY_ID=minio_user
8+
AWS_SECRET_ACCESS_KEY=minio_password

.devcontainer/init.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
NVMRC_VERSION="$(head -1 .nvmrc | sed 's/v//' | tr --delete '\n')"
3+
nvm install
4+
nvm use
5+
nvm alias default $(node --version)
6+
nvm install-latest-npm
7+
npm i

.devcontainer/minio.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
MINIO_ACCESS_KEY=minio_user
2+
MINIO_SECRET_KEY=minio_password

.devcontainer/workspace.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IMGPROXY_URL=http://localhost:4000
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish npm package
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish:
9+
if: github.repository_owner == 'bitpatty'
10+
name: Publish NPM package (GitHub Registry)
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-node@v2
18+
with:
19+
node-version: '16.6.1'
20+
registry-url: 'https://npm.pkg.github.com'
21+
scope: '@bitpatty'
22+
- run: npm install
23+
- run: npm run build
24+
- run: echo "registry=https://npm.pkg.github.com/@bitpatty" >> .npmrc
25+
- run: npm publish
26+
env:
27+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
29+
# publish-npmjs:
30+
# name: Publish NPM package (npmjs.org)
31+
# runs-on: ubuntu-latest
32+
# environment: npm-registry
33+
# steps:
34+
# - uses: actions/checkout@v2
35+
# - uses: actions/setup-node@v2
36+
# with:
37+
# node-version: '16.6.1'
38+
# registry-url: 'https://registry.npmjs.org'
39+
# - run: npm install
40+
# - run: npm publish
41+
# env:
42+
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.vscode
2+
example
3+
src
4+
.nvmrc
5+
.prettierrc
6+
rollup.config.js
7+
test.js
8+
tsconfig.json

0 commit comments

Comments
 (0)