Skip to content

Commit

Permalink
fix env (#284)
Browse files Browse the repository at this point in the history
* fix env

* fix

* fix

* fix
  • Loading branch information
itsumura-h authored Oct 12, 2024
1 parent 4bad067 commit 2e45dce
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 60 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/nim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ jobs:
runs-on: ubuntu-latest
needs: before
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Build docker image
run: docker compose -f compose.test.yaml build app-ubuntu-v1
- name: Test
run: docker compose -f compose.test.yaml run app-ubuntu-v1 nimble test

test-on-docker-nim-v2:
runs-on: ubuntu-latest
needs: before
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Build docker image
run: docker compose -f compose.test.yaml build app-ubuntu-v2
- name: Test
run: docker compose -f compose.test.yaml run app-ubuntu nimble test
run: docker compose -f compose.test.yaml run app-ubuntu-v2 nimble test


# アプリケーションの方を使うことにした
Expand Down
14 changes: 6 additions & 8 deletions compose.test.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
version: '3'
services:
app-ubuntu-v1:
build:
context: .
dockerfile: ./docker/ubuntu/Dockerfile
dockerfile: ./docker/ubuntu/test.Dockerfile
args:
VERSION: 1.6.16
NIM_VERSION: 1.6.20
tty: true
volumes:
- .:/root/project
Expand All @@ -15,12 +14,12 @@ services:
- mariadb
- surreal

app-ubuntu:
app-ubuntu-v2:
build:
context: .
dockerfile: ./docker/ubuntu/Dockerfile
dockerfile: ./docker/ubuntu/test.Dockerfile
args:
VERSION: 2.0.0
NIM_VERSION: 2.2.0
tty: true
volumes:
- .:/root/project
Expand All @@ -33,12 +32,11 @@ services:
mysql:
image: mysql:8
tty: true
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: database
MYSQL_USER: user
MYSQL_PASSWORD: pass
MYSQL_ROOT_PASSWORD: pass

mariadb:
image: mariadb
Expand Down
35 changes: 4 additions & 31 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
version: '3'
services:
# app-alpine:
# build:
# context: .
# dockerfile: ./docker/alpine/Dockerfile
# tty: true
# environment:
# TZ: Asia/Tokyo
# volumes:
# - .:/root/project
# depends_on:
# - mariadb
# - postgres

app-ubuntu:
build:
context: .
dockerfile: ./docker/ubuntu/Dockerfile
args:
# VERSION: 1.6.14
VERSION: 2.0.0
NIM_VERSION: 2.2.0
tty: true
volumes:
- .:/root/project
Expand All @@ -32,12 +18,11 @@ services:
mysql:
image: mysql:8
tty: true
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: database
MYSQL_USER: user
MYSQL_PASSWORD: pass
MYSQL_ROOT_PASSWORD: pass

mariadb:
image: mariadb
Expand All @@ -47,7 +32,6 @@ services:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: database
MYSQL_USER: user
MYSQL_PASSWORD: pass

postgres:
image: postgres:alpine
Expand All @@ -69,7 +53,7 @@ services:
image: adminer:4.8.1-standalone
tty: true
ports:
- 9002:8080
- 9001:8080
depends_on:
- mysql
- mariadb
Expand All @@ -79,19 +63,8 @@ services:
build: ./docker/adminer
tty: true
ports:
- 9003:8080
- 9002:8080
volumes:
- ./:/app
depends_on:
- app-ubuntu

phpmyadmin:
image: phpmyadmin
tty: true
environment:
- PMA_ARBITRARY=1
ports:
- "9004:80"
depends_on:
- mysql
- mariadb
46 changes: 29 additions & 17 deletions docker/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
FROM ubuntu:22.04
FROM ubuntu:24.04

# prevent timezone dialogue
ENV DEBIAN_FRONTEND=noninteractive

RUN apt update; apt install -y libgnutls30
RUN apt update; \
apt upgrade -y
RUN apt update
RUN apt upgrade -y
RUN apt install -y \
gcc \
xz-utils \
ca-certificates \
vim \
curl \
wget \
git \
sqlite3 \
libpq-dev \
libmariadb-dev
gcc \
xz-utils \
ca-certificates \
libpcre3-dev \
vim \
curl \
git \
sqlite3 \
libpq-dev \
libmariadb-dev

# ===== Nim =====
ARG VERSION="2.0.0"
# gcc... for Nim
# xz-utils... for unzip tar.xz
# ca-certificates... for https
# libpcre3-dev... for nim regex

# Nim
ARG NIM_VERSION="2.0.0"
WORKDIR /root
RUN curl https://nim-lang.org/choosenim/init.sh -o init.sh
RUN sh init.sh -y
RUN rm -f init.sh
ENV PATH $PATH:/root/.nimble/bin
RUN choosenim ${VERSION}
RUN choosenim ${NIM_VERSION}

# nimlangserver
WORKDIR /root
RUN curl -o nimlangserver.tar.gz -L https://github.com/nim-lang/langserver/releases/download/v1.6.0/nimlangserver-1.6.0-linux-amd64.tar.gz
RUN tar zxf nimlangserver.tar.gz
RUN rm -f nimlangserver.tar.gz
RUN mv nimlangserver /root/.nimble/bin/

WORKDIR /root/project
COPY ./allographer.nimble .
RUN nimble install -y -d

RUN git config --global --add safe.directory /root/project
39 changes: 39 additions & 0 deletions docker/ubuntu/test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ubuntu:24.04

# prevent timezone dialogue
ENV DEBIAN_FRONTEND=noninteractive

RUN apt update
RUN apt upgrade -y
RUN apt install -y \
gcc \
xz-utils \
ca-certificates \
libpcre3-dev \
curl \
git \
sqlite3 \
libpq-dev \
libmariadb-dev

# gcc... for Nim
# xz-utils... for unzip tar.xz
# ca-certificates... for https
# libpcre3-dev... for nim regex

# Nim
ARG NIM_VERSION="2.0.0"
WORKDIR /root
RUN curl https://nim-lang.org/choosenim/init.sh -o init.sh
RUN sh init.sh -y
RUN rm -f init.sh
ENV PATH $PATH:/root/.nimble/bin
RUN choosenim ${NIM_VERSION}

WORKDIR /root/project
COPY ./allographer.nimble .
RUN nimble install -y -d

RUN git config --global --add safe.directory /root/project

WORKDIR /root/project
2 changes: 1 addition & 1 deletion permission.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ local_GID=$(id -g $USER)
echo 'start'
sudo chown ${local_UID}:${local_GID} * -R
echo '======================'
sudo chown ${local_UID}:${local_GID} .git -R
sudo chown ${local_UID}:${local_GID} .* -R
echo 'end'
2 changes: 2 additions & 0 deletions tests/v2/mysql/test_query.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ discard """
cmd: "nim c -d:reset -d:ssl -r $file"
"""

# nim c -d:reset -d:ssl -r tests/v2/mysql/test_query.nim

import std/unittest
import std/asyncdispatch
import std/httpclient
Expand Down

0 comments on commit 2e45dce

Please sign in to comment.