Skip to content

Commit

Permalink
feat: add github actions #11
Browse files Browse the repository at this point in the history
  • Loading branch information
weaigc committed Jul 31, 2023
1 parent 30b53b4 commit 622de96
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build Docker Image

on:
push:
branches:
- main

jobs:
github:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Login to github registry
uses: actions-hub/docker/login@master
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_REGISTRY_URL: docker.pkg.github.com

- name: Build :latest
if: success()
run: docker build -t docker.pkg.github.com/${{ github.repository }}/app:latest .

- name: Push to docker hub :latest
if: success()
uses: actions-hub/docker@master
with:
args: push docker.pkg.github.com/${{ github.repository }}:latest
17 changes: 8 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,30 @@ FROM node:18

ARG DEBIAN_FRONTEND=noninteractive

ENV BING_UA Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.0.0
ENV BING_COOKIE ""
ENV BING_HEADER ""

# Set home to the user's home directory
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH

# Set up a new user named "user" with user ID 1000
RUN useradd -o -u 1000 user
RUN useradd -o -u 1000 user && mkdir -p $HOME/app && chown -R $HOME/app

# Switch to the "user" user
USER user

# Set home to the user's home directory
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY --chown=user package*.json $HOME/app
COPY --chown=user package*.json $HOME/app/

RUN npm install

# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app
COPY --chown=user . $HOME/app/

RUN npm run build

Expand Down

0 comments on commit 622de96

Please sign in to comment.