Skip to content

Commit

Permalink
build(docker): add docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf authored and tiensonqin committed Dec 28, 2021
1 parent 297e679 commit 9acafb2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 45 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 13 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
38 changes: 0 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 9acafb2

Please sign in to comment.