Selaa lähdekoodia

build(docker): add docker build

Andelf 3 vuotta sitten
vanhempi
sitoutus
9acafb2745
3 muutettua tiedostoa jossa 47 lisäystä ja 45 poistoa
  1. 34 0
      .github/workflows/build-docker.yml
  2. 13 7
      Dockerfile
  3. 0 38
      README.md

+ 34 - 0
.github/workflows/build-docker.yml

@@ -0,0 +1,34 @@
+name: Build-Docker
+
+on:
+  workflow_dispatch:
+  workflow_call:
+
+env:
+  CLOJURE_VERSION: '1.10.1.727'
+
+jobs:
+
+  build-docker:
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+        with:
+          fetch-depth: 1
+          submodules: 'true'
+
+      - name: Build Docker
+        run: |
+          docker build -t ghcr.io/logseq/logseq-webapp:latest .
+
+      - name: Docker Login
+        uses: docker/login-action@v1
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Publish Docker Image
+        run: docker push ghcr.io/logseq/logseq-webapp:latest

+ 13 - 7
Dockerfile

@@ -1,5 +1,9 @@
 # NOTE: please keep it in sync with .github pipelines
-FROM clojure:openjdk-11-tools-deps-1.10.1.727
+
+# Builder image
+FROM clojure:openjdk-11-tools-deps-1.10.1.727 as builder
+
+ARG DEBIAN_FRONTEND=noninteractive
 
 RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
     apt-get install -y nodejs
@@ -10,11 +14,13 @@ RUN apt-get update && apt-get install ca-certificates && \
     apt-get update && \
     apt-get install -y yarn
 
-RUN useradd -ms /bin/bash logseq
+WORKDIR /data/
+
+# Build for static resources
+RUN git clone https://github.com/logseq/logseq.git &&  cd /data/logseq && yarn && yarn release && mv ./static ./public && rm -r ./public/workspaces
+
+# Web App Runner image
+FROM nginx:stable-alpine
 
-USER logseq
-WORKDIR /home/logseq
+COPY --from=builder /data/logseq/public /usr/share/nginx/html
 
-EXPOSE 3001
-EXPOSE 9630
-EXPOSE 8701

+ 0 - 38
README.md

@@ -146,44 +146,6 @@ yarn dev-electron-app
 yarn release-electron
 ```
 
-## Alternative: Docker based development environment
-
-Basically it just pre-installs Java, Clojure and NodeJS for your convenience.
-
-### 1. Fetch sources
-
-```bash
-git clone https://github.com/logseq/logseq
-```
-
-### 2. Build Docker image
-
-```bash
-cd logseq
-docker build -t logseq-docker .
-```
-
-### 3. Run Docker container
-
-#### MacOS/Linux
-
-```bash
-docker run -v $(pwd):/home/logseq/logseq -p 3001:3001 -p 9630:9630 -p 8701:8701 --rm -it logseq-docker /bin/bash
-```
-#### Windows
-
-```bash
-docker run -v %cd%:/home/logseq/logseq -p 3001:3001 -p 9630:9630 -p 8701:8701 --rm -it logseq-docker /bin/bash
-```
-
-### 4. Inside the container compile as described above
-
-```bash
-cd logseq
-yarn
-yarn watch
-```
-
 ## Thanks
 
 [![JetBrains](docs/assets/jetbrains.svg)](https://www.jetbrains.com/?from=logseq)