mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-22 20:42:40 +00:00
Create docker dev env (#220)
This commit is contained in:
parent
86ad88fb09
commit
3179762fd3
6 changed files with 82 additions and 13 deletions
34
Dockerfile
34
Dockerfile
|
@ -1,14 +1,23 @@
|
||||||
FROM alpine:3.19 AS build
|
FROM alpine:3.19 AS base
|
||||||
|
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk add --no-cache \
|
apk add --no-cache \
|
||||||
make \
|
make \
|
||||||
gcc \
|
shadow \
|
||||||
musl-dev \
|
openssl \
|
||||||
libstdc++
|
openssh \
|
||||||
|
curl \
|
||||||
|
wget \
|
||||||
|
git \
|
||||||
|
gnupg \
|
||||||
|
xz \
|
||||||
|
gcc \
|
||||||
|
musl-dev \
|
||||||
|
libstdc++
|
||||||
|
|
||||||
COPY --from=golang:1.21-alpine /usr/local/go/ /usr/local/go/
|
COPY --from=golang:1.21-alpine /usr/local/go/ /usr/local/go/
|
||||||
ENV PATH="/usr/local/go/bin:${PATH}"
|
ENV PATH="/usr/local/go/bin:${PATH}"
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
|
|
||||||
COPY --from=node:20-alpine /usr/local/ /usr/local/
|
COPY --from=node:20-alpine /usr/local/ /usr/local/
|
||||||
ENV NODE_PATH="/usr/local/lib/node_modules"
|
ENV NODE_PATH="/usr/local/lib/node_modules"
|
||||||
|
@ -18,10 +27,21 @@ WORKDIR /opengist
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|
||||||
|
FROM base AS dev
|
||||||
|
|
||||||
|
EXPOSE 6157 2222 16157
|
||||||
|
VOLUME /opengist
|
||||||
|
|
||||||
|
CMD ["make", "watch"]
|
||||||
|
|
||||||
|
|
||||||
|
FROM base AS build
|
||||||
|
|
||||||
RUN make
|
RUN make
|
||||||
|
|
||||||
|
|
||||||
FROM alpine:3.19 as run
|
FROM alpine:3.19 as prod
|
||||||
|
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk add --no-cache \
|
apk add --no-cache \
|
||||||
|
|
13
Makefile
13
Makefile
|
@ -1,4 +1,4 @@
|
||||||
.PHONY: all all_crosscompile install build_frontend build_backend build build_crosscompile build_docker watch_frontend watch_backend watch clean clean_docker check_changes go_mod fmt test
|
.PHONY: all all_crosscompile install build_frontend build_backend build build_crosscompile build_docker build_dev_docker run_dev_docker watch_frontend watch_backend watch clean clean_docker check_changes go_mod fmt test
|
||||||
|
|
||||||
# Specify the name of your Go binary output
|
# Specify the name of your Go binary output
|
||||||
BINARY_NAME := opengist
|
BINARY_NAME := opengist
|
||||||
|
@ -31,16 +31,23 @@ build_docker:
|
||||||
@echo "Building Docker image..."
|
@echo "Building Docker image..."
|
||||||
docker build -t $(BINARY_NAME):latest .
|
docker build -t $(BINARY_NAME):latest .
|
||||||
|
|
||||||
|
build_dev_docker:
|
||||||
|
@echo "Building Docker image..."
|
||||||
|
docker build -t $(BINARY_NAME)-dev:latest --target dev .
|
||||||
|
|
||||||
|
run_dev_docker:
|
||||||
|
docker run -v .:/opengist -p 6157:6157 -p 16157:16157 $(BINARY_NAME)-dev:latest
|
||||||
|
|
||||||
watch_frontend:
|
watch_frontend:
|
||||||
@echo "Building frontend assets..."
|
@echo "Building frontend assets..."
|
||||||
npx vite -c public/vite.config.js dev --port 16157
|
npx vite -c public/vite.config.js dev --port 16157 --host
|
||||||
|
|
||||||
watch_backend:
|
watch_backend:
|
||||||
@echo "Building Opengist binary..."
|
@echo "Building Opengist binary..."
|
||||||
OG_DEV=1 npx nodemon --watch '**/*' -e html,yml,go,js --signal SIGTERM --exec 'go run . --config config.yml'
|
OG_DEV=1 npx nodemon --watch '**/*' -e html,yml,go,js --signal SIGTERM --exec 'go run . --config config.yml'
|
||||||
|
|
||||||
watch:
|
watch:
|
||||||
@bash ./scripts/watch.sh
|
@sh ./scripts/watch.sh
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo "Cleaning up build artifacts..."
|
@echo "Cleaning up build artifacts..."
|
||||||
|
|
|
@ -90,7 +90,7 @@ Opengist is now running on port 6157, you can browse http://localhost:6157
|
||||||
|
|
||||||
### From source
|
### From source
|
||||||
|
|
||||||
Requirements : [Git](https://git-scm.com/downloads) (2.28+), [Go](https://go.dev/doc/install) (1.21+), [Node.js](https://nodejs.org/en/download/) (16+)
|
Requirements: [Git](https://git-scm.com/downloads) (2.28+), [Go](https://go.dev/doc/install) (1.21+), [Node.js](https://nodejs.org/en/download/) (16+), [Make](https://linux.die.net/man/1/make) (optional, but easier)
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
git clone https://github.com/thomiceli/opengist
|
git clone https://github.com/thomiceli/opengist
|
||||||
|
@ -101,6 +101,9 @@ make
|
||||||
|
|
||||||
Opengist is now running on port 6157, you can browse http://localhost:6157
|
Opengist is now running on port 6157, you can browse http://localhost:6157
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
To create and run a development environment, see [run-development.md](/docs/contributing/run-development.md).
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
|
|
38
docs/contributing/run-development.md
Normal file
38
docs/contributing/run-development.md
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# Run Opengist in development mode
|
||||||
|
|
||||||
|
## With Docker
|
||||||
|
|
||||||
|
Assuming you have [Make](https://linux.die.net/man/1/make) installed,
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# Clone the repository
|
||||||
|
git clone git@github.com:thomiceli/opengist.git
|
||||||
|
cd opengist
|
||||||
|
|
||||||
|
# Build the development image
|
||||||
|
make build_dev_docker
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can run the development image with the following command:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
make run_dev_docker
|
||||||
|
```
|
||||||
|
|
||||||
|
Opengist is now running on port 6157, you can browse http://localhost:6157
|
||||||
|
|
||||||
|
## As a binary
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
* [Git](https://git-scm.com/downloads) (2.28+)
|
||||||
|
* [Go](https://go.dev/doc/install) (1.21+)
|
||||||
|
* [Node.js](https://nodejs.org/en/download/) (16+)
|
||||||
|
* [Make](https://linux.die.net/man/1/make) (optional, but easier)
|
||||||
|
|
||||||
|
```shell
|
||||||
|
git clone git@github.com:thomiceli/opengist.git
|
||||||
|
cd opengist
|
||||||
|
make watch
|
||||||
|
```
|
||||||
|
|
||||||
|
Opengist is now running on port 6157, you can browse http://localhost:6157
|
|
@ -58,10 +58,11 @@ chmod +x opengist
|
||||||
|
|
||||||
## From source
|
## From source
|
||||||
|
|
||||||
Requirements :
|
Requirements:
|
||||||
* [Git](https://git-scm.com/downloads) (2.28+)
|
* [Git](https://git-scm.com/downloads) (2.28+)
|
||||||
* [Go](https://go.dev/doc/install) (1.21+)
|
* [Go](https://go.dev/doc/install) (1.21+)
|
||||||
* [Node.js](https://nodejs.org/en/download/) (16+)
|
* [Node.js](https://nodejs.org/en/download/) (16+)
|
||||||
|
* [Make](https://linux.die.net/man/1/make) (optional, but easier)
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
git clone https://github.com/thomiceli/opengist
|
git clone https://github.com/thomiceli/opengist
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
make watch_frontend &
|
make watch_frontend &
|
||||||
|
|
Loading…
Reference in a new issue