Skip to content

Commit

Permalink
Merge pull request #7 from YTVanced/dev
Browse files Browse the repository at this point in the history
Testing API url from build args
  • Loading branch information
VancedOfficial authored Nov 13, 2020
2 parents 9c7c872 + a24c75e commit 68d27a9
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 4 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
.dockerignore
.env
Dockerfile
.github
coverage
4 changes: 3 additions & 1 deletion .github/workflows/dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
uses: docker/build-push-action@v2
with:
push: true
tags: vanced/website-v2:dev-${{ env.RELEASE_VERSION }}
tags: vanced/website-v2:dev-${{ env.RELEASE_VERSION }},vanced/website-v2:dev-latest
build-args: |
REACT_APP_VANCED_LATEST_API_URL=${{ secrets.REACT_APP_VANCED_LATEST_API_URL_DEV }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Pull and update a new version
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/prod-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
uses: docker/build-push-action@v2
with:
push: true
tags: vanced/website-v2:${{ env.RELEASE_VERSION }}
tags: vanced/website-v2:${{ env.RELEASE_VERSION }},vanced/website-v2:latest
build-args: |
REACT_APP_VANCED_LATEST_API_URL=${{ secrets.REACT_APP_VANCED_LATEST_API_URL }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Pull and update a new version
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ RUN cd /src && npm install --loglevel error
RUN npm install -g serve
COPY . /src
WORKDIR /src

# Add environment variables
ARG REACT_APP_VANCED_LATEST_API_URL
RUN echo "REACT_APP_VANCED_LATEST_API_URL=$REACT_APP_VANCED_LATEST_API_URL" >> .env

EXPOSE 4001
RUN npm run build
CMD serve -s build -l 4001
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
Based on the template from https://github.com/facebook/create-react-app

Vanced Website Repo (https://vancedapp.com)
Vanced Website Repo (https://vancedapp.com)

## Developing

### 1. Running
```
npm start
```

## Docker testing

### 1. Building local image
```
docker build --build-arg REACT_APP_VANCED_LATEST_API_URL=https://cors-anywhere.herokuapp.com/https://vancedapp.com/api/v1/latest.json -t vanced/website-v2:local .
```

### 2. Running the container
```
docker-compose up
```

Or to run in detached mode

```
docker-compose up -d
```

### 3. Open the site
Go to http://localhost:4001/
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '3'
services:
backend:
image: vanced/website-v2:local
ports:
- "4001:4001"
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const App = () => {
const [changeLogs, setChangeLogs] = useState({});

useEffect(() => {
fetch("https://vancedapp.com/api/v1/latest.json")
fetch(process.env.REACT_APP_VANCED_LATEST_API_URL)
.then(res => res.json())
.then(data => setChangeLogs(data));
}, []);
Expand Down

0 comments on commit 68d27a9

Please sign in to comment.